mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-08-02 17:58:26 +00:00
Compare commits
No commits in common. "main" and "WAMR-2.4.0" have entirely different histories.
main
...
WAMR-2.4.0
46
.github/scripts/run_qemu_arc.sh
vendored
46
.github/scripts/run_qemu_arc.sh
vendored
|
@ -1,46 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# THIS SCRIPT IS USED TO RUN QEMU ARC EMULATOR DIRECTLY ON CI ONLY.
|
||||
# USUALLY, you SHOULD NOT RUN IT ON YOUR LOCAL MACHINE.
|
||||
# INSTEAD, YOU SHOULD USE `west build -t run` COMMAND.
|
||||
|
||||
# Two arguments. first is the path to the zephyr-sdk, second is the path to the zephyr elf.
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <path_to_zephyr_sdk> <path_to_zephyr_elf>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ZEPHYR_SDK_PATH=$1
|
||||
ZEPHYR_ELF_PATH=$2
|
||||
|
||||
if [ ! -d "$ZEPHYR_SDK_PATH" ]; then
|
||||
echo "Error: Zephyr SDK path does not exist: $ZEPHYR_SDK_PATH"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$ZEPHYR_ELF_PATH" ]; then
|
||||
echo "Error: Zephyr ELF file does not exist: $ZEPHYR_ELF_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# this command is copied from the content of build.ninja which is generated by west build.
|
||||
# please do not modify it unless synchronizing with the build.ninja file.
|
||||
$ZEPHYR_SDK_PATH/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-system-arc \
|
||||
-cpu arcem -m 8M \
|
||||
-nographic -no-reboot -monitor none \
|
||||
-global cpu.firq=false \
|
||||
-global cpu.num-irqlevels=15 \
|
||||
-global cpu.num-irq=25 \
|
||||
-global cpu.ext-irq=20 \
|
||||
-global cpu.freq_hz=10000000 \
|
||||
-global cpu.timer0=true \
|
||||
-global cpu.timer1=true \
|
||||
-global cpu.has-mpu=true \
|
||||
-global cpu.mpu-numreg=16 \
|
||||
-net none \
|
||||
-pidfile qemu.pid \
|
||||
-chardev stdio,id=con,mux=on \
|
||||
-serial chardev:con \
|
||||
-mon chardev=con,mode=readline \
|
||||
-icount shift=6,align=off,sleep=off \
|
||||
-rtc clock=vm \
|
||||
-kernel $ZEPHYR_ELF_PATH
|
130
.github/workflows/build_iwasm_release.yml
vendored
130
.github/workflows/build_iwasm_release.yml
vendored
|
@ -32,60 +32,60 @@ on:
|
|||
required: false
|
||||
|
||||
env:
|
||||
DEFAULT_BUILD_OPTIONS:
|
||||
DEFAULT_BUILD_OPTIONS:
|
||||
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \
|
||||
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
|
||||
-DWAMR_BUILD_DEBUG_INTERP=0 \
|
||||
-DWAMR_BUILD_DEBUG_AOT=0 \
|
||||
-DWAMR_BUILD_DUMP_CALL_STACK=0 \
|
||||
-DWAMR_BUILD_LIBC_UVWASI=0 \
|
||||
-DWAMR_BUILD_LIBC_EMCC=0 \
|
||||
-DWAMR_BUILD_LIB_RATS=0 \
|
||||
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
|
||||
-DWAMR_BUILD_MEMORY_PROFILING=0 \
|
||||
-DWAMR_BUILD_MINI_LOADER=0 \
|
||||
-DWAMR_BUILD_MULTI_MODULE=0 \
|
||||
-DWAMR_BUILD_PERF_PROFILING=0 \
|
||||
-DWAMR_BUILD_SPEC_TEST=0 \
|
||||
-DWAMR_BUILD_BULK_MEMORY=1 \
|
||||
-DWAMR_BUILD_LIB_PTHREAD=1 \
|
||||
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
|
||||
-DWAMR_BUILD_LIB_WASI_THREADS=1 \
|
||||
-DWAMR_BUILD_LIBC_BUILTIN=1 \
|
||||
-DWAMR_BUILD_LIBC_WASI=1 \
|
||||
-DWAMR_BUILD_REF_TYPES=1 \
|
||||
-DWAMR_BUILD_SIMD=1 \
|
||||
-DWAMR_BUILD_SHARED_MEMORY=1 \
|
||||
-DWAMR_BUILD_TAIL_CALL=1 \
|
||||
-DWAMR_BUILD_THREAD_MGR=1"
|
||||
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
|
||||
-DWAMR_BUILD_DEBUG_INTERP=0 \
|
||||
-DWAMR_BUILD_DEBUG_AOT=0 \
|
||||
-DWAMR_BUILD_DUMP_CALL_STACK=0 \
|
||||
-DWAMR_BUILD_LIBC_UVWASI=0 \
|
||||
-DWAMR_BUILD_LIBC_EMCC=0 \
|
||||
-DWAMR_BUILD_LIB_RATS=0 \
|
||||
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
|
||||
-DWAMR_BUILD_MEMORY_PROFILING=0 \
|
||||
-DWAMR_BUILD_MINI_LOADER=0 \
|
||||
-DWAMR_BUILD_MULTI_MODULE=0 \
|
||||
-DWAMR_BUILD_PERF_PROFILING=0 \
|
||||
-DWAMR_BUILD_SPEC_TEST=0 \
|
||||
-DWAMR_BUILD_BULK_MEMORY=1 \
|
||||
-DWAMR_BUILD_LIB_PTHREAD=1 \
|
||||
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
|
||||
-DWAMR_BUILD_LIB_WASI_THREADS=1 \
|
||||
-DWAMR_BUILD_LIBC_BUILTIN=1 \
|
||||
-DWAMR_BUILD_LIBC_WASI=1 \
|
||||
-DWAMR_BUILD_REF_TYPES=1 \
|
||||
-DWAMR_BUILD_SIMD=1 \
|
||||
-DWAMR_BUILD_SHARED_MEMORY=1 \
|
||||
-DWAMR_BUILD_TAIL_CALL=1 \
|
||||
-DWAMR_BUILD_THREAD_MGR=1"
|
||||
GC_EH_BUILD_OPTIONS:
|
||||
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 \
|
||||
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
|
||||
-DWAMR_BUILD_DEBUG_INTERP=0 \
|
||||
-DWAMR_BUILD_DEBUG_AOT=0 \
|
||||
-DWAMR_BUILD_DUMP_CALL_STACK=0 \
|
||||
-DWAMR_BUILD_LIBC_UVWASI=0 \
|
||||
-DWAMR_BUILD_LIBC_EMCC=0 \
|
||||
-DWAMR_BUILD_LIB_RATS=0 \
|
||||
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
|
||||
-DWAMR_BUILD_MEMORY_PROFILING=0 \
|
||||
-DWAMR_BUILD_MINI_LOADER=0 \
|
||||
-DWAMR_BUILD_MULTI_MODULE=0 \
|
||||
-DWAMR_BUILD_PERF_PROFILING=0 \
|
||||
-DWAMR_BUILD_SPEC_TEST=0 \
|
||||
-DWAMR_BUILD_BULK_MEMORY=1 \
|
||||
-DWAMR_BUILD_LIB_PTHREAD=1 \
|
||||
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
|
||||
-DWAMR_BUILD_LIB_WASI_THREADS=1 \
|
||||
-DWAMR_BUILD_LIBC_BUILTIN=1 \
|
||||
-DWAMR_BUILD_LIBC_WASI=1 \
|
||||
-DWAMR_BUILD_REF_TYPES=1 \
|
||||
-DWAMR_BUILD_SIMD=1 \
|
||||
-DWAMR_BUILD_SHARED_MEMORY=1 \
|
||||
-DWAMR_BUILD_TAIL_CALL=1 \
|
||||
-DWAMR_BUILD_THREAD_MGR=1 \
|
||||
-DWAMR_BUILD_EXCE_HANDLING=1 \
|
||||
-DWAMR_BUILD_GC=1"
|
||||
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
|
||||
-DWAMR_BUILD_DEBUG_INTERP=0 \
|
||||
-DWAMR_BUILD_DEBUG_AOT=0 \
|
||||
-DWAMR_BUILD_DUMP_CALL_STACK=0 \
|
||||
-DWAMR_BUILD_LIBC_UVWASI=0 \
|
||||
-DWAMR_BUILD_LIBC_EMCC=0 \
|
||||
-DWAMR_BUILD_LIB_RATS=0 \
|
||||
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
|
||||
-DWAMR_BUILD_MEMORY_PROFILING=0 \
|
||||
-DWAMR_BUILD_MINI_LOADER=0 \
|
||||
-DWAMR_BUILD_MULTI_MODULE=0 \
|
||||
-DWAMR_BUILD_PERF_PROFILING=0 \
|
||||
-DWAMR_BUILD_SPEC_TEST=0 \
|
||||
-DWAMR_BUILD_BULK_MEMORY=1 \
|
||||
-DWAMR_BUILD_LIB_PTHREAD=1 \
|
||||
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
|
||||
-DWAMR_BUILD_LIB_WASI_THREADS=1 \
|
||||
-DWAMR_BUILD_LIBC_BUILTIN=1 \
|
||||
-DWAMR_BUILD_LIBC_WASI=1 \
|
||||
-DWAMR_BUILD_REF_TYPES=1 \
|
||||
-DWAMR_BUILD_SIMD=1 \
|
||||
-DWAMR_BUILD_SHARED_MEMORY=1 \
|
||||
-DWAMR_BUILD_TAIL_CALL=1 \
|
||||
-DWAMR_BUILD_THREAD_MGR=1 \
|
||||
-DWAMR_BUILD_EXCE_HANDLING=1 \
|
||||
-DWAMR_BUILD_GC=1"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
@ -97,9 +97,9 @@ jobs:
|
|||
matrix:
|
||||
include:
|
||||
- build_options: $DEFAULT_BUILD_OPTIONS
|
||||
suffix: ""
|
||||
suffix: ''
|
||||
- build_options: $GC_EH_BUILD_OPTIONS
|
||||
suffix: "-gc-eh"
|
||||
suffix: '-gc-eh'
|
||||
permissions:
|
||||
contents: write # for uploading release artifacts
|
||||
|
||||
|
@ -126,30 +126,6 @@ jobs:
|
|||
cmake --build build --config Release --parallel 4
|
||||
working-directory: ${{ inputs.cwd }}
|
||||
|
||||
- name: smoke test on non-Windows
|
||||
if: ${{ !startsWith(inputs.runner, 'windows') }}
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ ! -f build/iwasm ]]; then
|
||||
echo "iwasm binary is not found in the expected location."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
build/iwasm --version
|
||||
working-directory: ${{ inputs.cwd }}
|
||||
|
||||
- name: smoke test on Windows
|
||||
if: ${{ startsWith(inputs.runner, 'windows') }}
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ ! -f build/Release/iwasm ]]; then
|
||||
echo "iwasm binary is not found in the expected location."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
build/Release/iwasm --version
|
||||
working-directory: ${{ inputs.cwd }}
|
||||
|
||||
- name: Compress the binary on Windows
|
||||
if: inputs.runner == 'windows-latest'
|
||||
run: |
|
||||
|
|
24
.github/workflows/build_wamrc.yml
vendored
24
.github/workflows/build_wamrc.yml
vendored
|
@ -62,30 +62,6 @@ jobs:
|
|||
cmake --build build --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: smoke test on non-windows
|
||||
if: ${{ !startsWith(inputs.runner, 'windows') }}
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ ! -f build/wamrc ]]; then
|
||||
echo "wamrc binary is not found in the expected location."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
build/wamrc --version
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: smoke test on Windows
|
||||
if: ${{ startsWith(inputs.runner, 'windows') }}
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ ! -f build/Release/wamrc ]]; then
|
||||
echo "wamrc binary is not found in the expected location."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
build/Release/wamrc --version
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: Compress the binary on Windows
|
||||
if: inputs.runner == 'windows-latest' && inputs.release
|
||||
run: |
|
||||
|
|
6
.github/workflows/codeql.yml
vendored
6
.github/workflows/codeql.yml
vendored
|
@ -53,7 +53,7 @@ jobs:
|
|||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3.29.4
|
||||
uses: github/codeql-action/init@v3.29.2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
|
@ -70,7 +70,7 @@ jobs:
|
|||
- run: |
|
||||
./.github/scripts/codeql_buildscript.sh
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3.29.4
|
||||
uses: github/codeql-action/analyze@v3.29.2
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
upload: false
|
||||
|
@ -99,7 +99,7 @@ jobs:
|
|||
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
|
||||
|
||||
- name: Upload CodeQL results to code scanning
|
||||
uses: github/codeql-action/upload-sarif@v3.29.4
|
||||
uses: github/codeql-action/upload-sarif@v3.29.2
|
||||
with:
|
||||
sarif_file: ${{ steps.step1.outputs.sarif-output }}
|
||||
category: "/language:${{matrix.language}}"
|
||||
|
|
|
@ -371,47 +371,6 @@ jobs:
|
|||
ctest
|
||||
working-directory: tests/unit
|
||||
|
||||
build_regression_tests:
|
||||
needs:
|
||||
[build_llvm_libraries_on_ubuntu_2204]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-22.04]
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: Build wamrc and iwasm
|
||||
run: |
|
||||
./build_wamr.sh
|
||||
working-directory: tests/regression/ba-issues
|
||||
|
||||
- name: Run regression tests
|
||||
run: |
|
||||
python run.py
|
||||
working-directory: tests/regression/ba-issues
|
||||
|
||||
build_samples_wasm_c_api:
|
||||
needs:
|
||||
[
|
||||
|
|
129
.github/workflows/compilation_on_zephyr.yml
vendored
129
.github/workflows/compilation_on_zephyr.yml
vendored
|
@ -1,129 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: compilation on zephyr
|
||||
|
||||
on:
|
||||
# will be triggered on PR events
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
paths:
|
||||
- ".github/**"
|
||||
- "build-scripts/**"
|
||||
- "core/**"
|
||||
- "!core/deps/**"
|
||||
- "product-mini/platforms/common/**"
|
||||
- "product-mini/platforms/zephyr/**"
|
||||
- "samples/**"
|
||||
- "!samples/workload/**"
|
||||
- "tests/wamr-test-suites/**"
|
||||
- "wamr-compiler/**"
|
||||
# will be triggered on push events
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- "dev/**"
|
||||
paths:
|
||||
- ".github/**"
|
||||
- "build-scripts/**"
|
||||
- "core/**"
|
||||
- "!core/deps/**"
|
||||
- "product-mini/platforms/common/**"
|
||||
- "product-mini/platforms/zephyr/**"
|
||||
- "samples/**"
|
||||
- "!samples/workload/**"
|
||||
- "tests/wamr-test-suites/**"
|
||||
- "wamr-compiler/**"
|
||||
# allow to be triggered manually
|
||||
workflow_dispatch:
|
||||
|
||||
# Cancel any in-flight jobs for the same PR/branch so there's only one active
|
||||
# at a time
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
# FOR SETUP
|
||||
ZEPHYR_SDK_VERSION: "0.16.9"
|
||||
ZEPHYR_VERSION: "v3.7.0"
|
||||
# FOR BUILD
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
smoke_test:
|
||||
runs-on: ubuntu-22.04
|
||||
container:
|
||||
# For Zephyr 3.7 LTS, use the v0.26-branch or the latest v0.26.x release Docker image.
|
||||
# ci require a larger runner to avoid "no space left on device"
|
||||
image: ghcr.io/zephyrproject-rtos/ci-base:v0.26-branch
|
||||
options: --user root
|
||||
|
||||
steps:
|
||||
# https://docs.zephyrproject.org/latest/develop/application/index.html#zephyr-workspace-application
|
||||
# zephyrproject/ --> CI ROOT
|
||||
# ├─── .west/
|
||||
# │ └─── config
|
||||
# ├─── bootloader/
|
||||
# ├─── zephyr/ --> Zephyr source code
|
||||
# ├─── zephyr-sdk/
|
||||
# ├─── modules/
|
||||
# │ |─── wasm-micro-runtime --> WAMR source code
|
||||
# ├─── tools/
|
||||
# ├─── vendor/
|
||||
# └─── application/ --> DUMMY. keep west_lite.yml here
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: modules/wasm-micro-runtime
|
||||
|
||||
- name: Prepare Zephyr environment
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p application
|
||||
cp modules/wasm-micro-runtime/product-mini/platforms/zephyr/simple/west_lite.yml application/west_lite.yml
|
||||
|
||||
- name: Setup Zephyr project
|
||||
uses: zephyrproject-rtos/action-zephyr-setup@v1
|
||||
with:
|
||||
app-path: application
|
||||
manifest-file-name: west_lite.yml
|
||||
sdk-version: ${{ env.ZEPHYR_SDK_VERSION }}
|
||||
toolchains: arc-zephyr-elf:arc64-zephyr-elf
|
||||
|
||||
- name: Build a sample application(simple)
|
||||
shell: bash
|
||||
run: |
|
||||
pushd product-mini/platforms/zephyr/simple
|
||||
west build . -b qemu_arc/qemu_arc_hs -p always -- -DWAMR_BUILD_TARGET=ARC
|
||||
popd
|
||||
|
||||
# west build -t run will fork several processes, which will cause the job to hang.
|
||||
# run in the background and kill it after 5 seconds
|
||||
.github/scripts/run_qemu_arc.sh \
|
||||
../../zephyr-sdk \
|
||||
product-mini/platforms/zephyr/simple/build/zephyr/zephyr.elf &
|
||||
sleep 5
|
||||
pkill qemu-system-arc
|
||||
working-directory: modules/wasm-micro-runtime
|
||||
|
||||
- name: Build a sample application(user-mode)
|
||||
shell: bash
|
||||
run: |
|
||||
pushd product-mini/platforms/zephyr/user-mode
|
||||
west build . -b qemu_arc/qemu_arc_hs -p always -- -DWAMR_BUILD_TARGET=ARC
|
||||
popd
|
||||
|
||||
# west build -t run will fork several processes, which will cause the job to hang.
|
||||
# run in the background and kill it after 5 seconds
|
||||
.github/scripts/run_qemu_arc.sh \
|
||||
../../zephyr-sdk \
|
||||
product-mini/platforms/zephyr/user-mode/build/zephyr/zephyr.elf &
|
||||
sleep 5
|
||||
pkill qemu-system-arc
|
||||
working-directory: modules/wasm-micro-runtime
|
2
.github/workflows/supply_chain.yml
vendored
2
.github/workflows/supply_chain.yml
vendored
|
@ -60,6 +60,6 @@ jobs:
|
|||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@701df0e49d84a24bd8f0d01f80c0dbf69ab07674
|
||||
uses: github/codeql-action/upload-sarif@b69421388d5449cc5a5e1ca344d71926bda69e07
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
|
|
@ -1,38 +1,3 @@
|
|||
## WAMR-2.4.1
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- wasi_socket_ext.c: fix error reporting (#4476)
|
||||
- lib-socket: make getaddrinfo return EAI\_ values (#4498)
|
||||
- bump AOT_CURRENT_VERSION for extended-const (#4511)
|
||||
|
||||
### New Features
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- modify macro related to simde when WASM_OP_SELECT_128 (#4461)
|
||||
- posix os_socket_accept: stop assuming socklen_t is unsigned int (#4488)
|
||||
- wasi_socket_ext.c: fix the number of getaddrinfo results (#4466)
|
||||
- Fix typos (#4472)
|
||||
- fix regression running_config.json (#4477)
|
||||
- posix os_socket_addr_resolve: relax compatibility check (#4469)
|
||||
- Add validation for recursive type count in loader (#4440)
|
||||
|
||||
### Enhancements
|
||||
|
||||
- Add CI on Zephyr (#4336)
|
||||
- introduce wasm_runtime_instantiate_ex2 (#4444)
|
||||
- Add a CLI option to specify shared heap size on Windows platform (#4503)
|
||||
- wasi-nn: add a comment on load_by_name_with_config (#4492)
|
||||
- nn-cli: add an option to use load_by_name (#4490)
|
||||
- wamr-wasi-extensions: document (#4493)
|
||||
- doc/socket_api.md: some historical notes (#4494)
|
||||
- lib-socket: implement getsockopt(SOL_SOCKET,SO_TYPE) (#4458)
|
||||
|
||||
### Others
|
||||
|
||||
- build(deps): Bump github/codeql-action from 3.29.2 to 3.29.3 (#4507)
|
||||
|
||||
## WAMR-2.4.0
|
||||
|
||||
### Breaking Changes
|
||||
|
|
|
@ -8,7 +8,7 @@ endif()
|
|||
|
||||
set(WAMR_VERSION_MAJOR 2)
|
||||
set(WAMR_VERSION_MINOR 4)
|
||||
set(WAMR_VERSION_PATCH 1)
|
||||
set(WAMR_VERSION_PATCH 0)
|
||||
|
||||
message("-- WAMR version: ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}")
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
#endif
|
||||
|
||||
#define AOT_MAGIC_NUMBER 0x746f6100
|
||||
#define AOT_CURRENT_VERSION 5
|
||||
#define AOT_CURRENT_VERSION 4
|
||||
|
||||
#ifndef WASM_ENABLE_JIT
|
||||
#define WASM_ENABLE_JIT 0
|
||||
|
|
|
@ -1786,8 +1786,7 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
|
|||
|
||||
read_uint32(buf, buf_end, j);
|
||||
#if WASM_ENABLE_AOT_VALIDATOR != 0
|
||||
/* an equivalence type should be before the type it refers to */
|
||||
if (j > i) {
|
||||
if (j >= module->type_count) {
|
||||
set_error_buf(error_buf, error_buf_size, "invalid type index");
|
||||
goto fail;
|
||||
}
|
||||
|
@ -1806,12 +1805,7 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
|
|||
read_uint32(buf, buf_end, parent_type_idx);
|
||||
read_uint16(buf, buf_end, rec_count);
|
||||
read_uint16(buf, buf_end, rec_idx);
|
||||
#if WASM_ENABLE_AOT_VALIDATOR != 0
|
||||
if (rec_idx > i) {
|
||||
set_error_buf(error_buf, error_buf_size, "invalid rec_idx");
|
||||
goto fail;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (type_flag == WASM_TYPE_FUNC) {
|
||||
AOTFuncType *func_type;
|
||||
|
||||
|
@ -4421,7 +4415,7 @@ aot_compatible_version(uint32 version)
|
|||
* refer to "AoT-compiled module compatibility among WAMR versions" in
|
||||
* ./doc/biuld_wasm_app.md
|
||||
*/
|
||||
return version == AOT_CURRENT_VERSION;
|
||||
return version == 4 || version == 3;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
|
@ -79,6 +79,3 @@ return:
|
|||
add sp, sp, #0x30 /* restore sp */
|
||||
ret
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
|
|
@ -77,6 +77,3 @@ return:
|
|||
add sp, sp, #0x30 /* restore sp */
|
||||
ret
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
|
|
@ -67,6 +67,3 @@ call_func:
|
|||
j_s [blink] /* ret */
|
||||
nop_s
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
|
|
@ -73,6 +73,3 @@ return:
|
|||
add sp, sp, #4
|
||||
ldmfd sp!, {r4, r5, r6, r7, lr}
|
||||
bx lr
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
|
|
@ -84,6 +84,3 @@ return:
|
|||
ldmfd sp!, {r4, r5, r6, r7, lr}
|
||||
bx lr
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
|
|
@ -62,6 +62,3 @@ push_args_end:
|
|||
leave
|
||||
ret
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
|
|
@ -62,6 +62,3 @@ push_args_end:
|
|||
leave
|
||||
ret
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
|
|
@ -35,6 +35,3 @@ skip_push_args:
|
|||
leave
|
||||
ret
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
|
|
@ -72,6 +72,3 @@ done:
|
|||
|
||||
j $31
|
||||
.end invokeNative
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
|
|
@ -15,4 +15,4 @@
|
|||
#else
|
||||
#include "invokeNative_em64_simd.s"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
|
@ -89,6 +89,3 @@ return:
|
|||
pop {r4, r5, r6, r7}
|
||||
mov lr, r3
|
||||
bx lr
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
|
|
@ -98,6 +98,3 @@ return:
|
|||
mov lr, r3
|
||||
bx lr
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
|
|
@ -72,6 +72,3 @@ call_func:
|
|||
|
||||
return:
|
||||
retw.n
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
|
|
@ -199,8 +199,6 @@ wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args)
|
|||
|
||||
heap->heap_handle = NULL;
|
||||
heap->base_addr = init_args->pre_allocated_addr;
|
||||
LOG_VERBOSE("Create preallocated shared heap %p with size %u",
|
||||
heap->base_addr, size);
|
||||
}
|
||||
else {
|
||||
if (!(heap->heap_handle =
|
||||
|
@ -227,8 +225,6 @@ wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args)
|
|||
LOG_WARNING("init share heap failed");
|
||||
goto fail4;
|
||||
}
|
||||
LOG_VERBOSE("Create pool shared heap %p with size %u", heap->base_addr,
|
||||
size);
|
||||
}
|
||||
|
||||
os_mutex_lock(&shared_heap_list_lock);
|
||||
|
@ -513,8 +509,6 @@ wasm_runtime_attach_shared_heap_internal(WASMModuleInstanceCommon *module_inst,
|
|||
os_mutex_lock(&shared_heap_list_lock);
|
||||
shared_heap->attached_count++;
|
||||
os_mutex_unlock(&shared_heap_list_lock);
|
||||
LOG_VERBOSE("Shared heap %p is attached to module instance %p", shared_heap,
|
||||
module_inst);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -576,7 +570,6 @@ wasm_runtime_detach_shared_heap_internal(WASMModuleInstanceCommon *module_inst)
|
|||
e->shared_heap_base_addr_adj = NULL;
|
||||
}
|
||||
#endif /* end of WASM_ENABLE_AOT != 0 */
|
||||
LOG_VERBOSE("Shared heap is detached from module instance %p", module_inst);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1654,70 +1654,14 @@ wasm_runtime_instantiate(WASMModuleCommon *module, uint32 stack_size,
|
|||
error_buf_size);
|
||||
}
|
||||
|
||||
static void
|
||||
instantiation_args_set_defaults(struct InstantiationArgs2 *args)
|
||||
{
|
||||
memset(args, 0, sizeof(*args));
|
||||
}
|
||||
|
||||
WASMModuleInstanceCommon *
|
||||
wasm_runtime_instantiate_ex(WASMModuleCommon *module,
|
||||
const InstantiationArgs *args, char *error_buf,
|
||||
uint32 error_buf_size)
|
||||
{
|
||||
struct InstantiationArgs2 v2;
|
||||
instantiation_args_set_defaults(&v2);
|
||||
v2.v1 = *args;
|
||||
return wasm_runtime_instantiate_ex2(module, &v2, error_buf, error_buf_size);
|
||||
}
|
||||
|
||||
bool
|
||||
wasm_runtime_instantiation_args_create(struct InstantiationArgs2 **p)
|
||||
{
|
||||
struct InstantiationArgs2 *args = wasm_runtime_malloc(sizeof(*args));
|
||||
if (args == NULL) {
|
||||
return false;
|
||||
}
|
||||
instantiation_args_set_defaults(args);
|
||||
*p = args;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
wasm_runtime_instantiation_args_destroy(struct InstantiationArgs2 *p)
|
||||
{
|
||||
wasm_runtime_free(p);
|
||||
}
|
||||
|
||||
void
|
||||
wasm_runtime_instantiation_args_set_default_stack_size(
|
||||
struct InstantiationArgs2 *p, uint32 v)
|
||||
{
|
||||
p->v1.default_stack_size = v;
|
||||
}
|
||||
|
||||
void
|
||||
wasm_runtime_instantiation_args_set_host_managed_heap_size(
|
||||
struct InstantiationArgs2 *p, uint32 v)
|
||||
{
|
||||
p->v1.host_managed_heap_size = v;
|
||||
}
|
||||
|
||||
void
|
||||
wasm_runtime_instantiation_args_set_max_memory_pages(
|
||||
struct InstantiationArgs2 *p, uint32 v)
|
||||
{
|
||||
p->v1.max_memory_pages = v;
|
||||
}
|
||||
|
||||
WASMModuleInstanceCommon *
|
||||
wasm_runtime_instantiate_ex2(WASMModuleCommon *module,
|
||||
const struct InstantiationArgs2 *args,
|
||||
char *error_buf, uint32 error_buf_size)
|
||||
{
|
||||
return wasm_runtime_instantiate_internal(
|
||||
module, NULL, NULL, args->v1.default_stack_size,
|
||||
args->v1.host_managed_heap_size, args->v1.max_memory_pages, error_buf,
|
||||
module, NULL, NULL, args->default_stack_size,
|
||||
args->host_managed_heap_size, args->max_memory_pages, error_buf,
|
||||
error_buf_size);
|
||||
}
|
||||
|
||||
|
@ -3810,15 +3754,7 @@ wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst,
|
|||
address = strtok(cp, "/");
|
||||
mask = strtok(NULL, "/");
|
||||
|
||||
if (!mask) {
|
||||
snprintf(error_buf, error_buf_size,
|
||||
"Invalid address pool entry: %s, must be in the format of "
|
||||
"ADDRESS/MASK",
|
||||
addr_pool[i]);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = addr_pool_insert(apool, address, (uint8)atoi(mask));
|
||||
ret = addr_pool_insert(apool, address, (uint8)(mask ? atoi(mask) : 0));
|
||||
wasm_runtime_free(cp);
|
||||
if (!ret) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
|
|
|
@ -612,10 +612,6 @@ WASMExecEnv *
|
|||
wasm_runtime_get_exec_env_tls(void);
|
||||
#endif
|
||||
|
||||
struct InstantiationArgs2 {
|
||||
InstantiationArgs v1;
|
||||
};
|
||||
|
||||
/* See wasm_export.h for description */
|
||||
WASM_RUNTIME_API_EXTERN bool
|
||||
wasm_runtime_init(void);
|
||||
|
@ -704,40 +700,6 @@ wasm_runtime_instantiate_ex(WASMModuleCommon *module,
|
|||
const InstantiationArgs *args, char *error_buf,
|
||||
uint32 error_buf_size);
|
||||
|
||||
/* See wasm_export.h for description */
|
||||
WASM_RUNTIME_API_EXTERN
|
||||
bool
|
||||
wasm_runtime_instantiation_args_create(struct InstantiationArgs2 **p);
|
||||
|
||||
/* See wasm_export.h for description */
|
||||
WASM_RUNTIME_API_EXTERN
|
||||
void
|
||||
wasm_runtime_instantiation_args_destroy(struct InstantiationArgs2 *p);
|
||||
|
||||
/* See wasm_export.h for description */
|
||||
WASM_RUNTIME_API_EXTERN
|
||||
void
|
||||
wasm_runtime_instantiation_args_set_default_stack_size(
|
||||
struct InstantiationArgs2 *p, uint32 v);
|
||||
|
||||
/* See wasm_export.h for description */
|
||||
WASM_RUNTIME_API_EXTERN
|
||||
void
|
||||
wasm_runtime_instantiation_args_set_host_managed_heap_size(
|
||||
struct InstantiationArgs2 *p, uint32 v);
|
||||
|
||||
/* See wasm_export.h for description */
|
||||
WASM_RUNTIME_API_EXTERN
|
||||
void
|
||||
wasm_runtime_instantiation_args_set_max_memory_pages(
|
||||
struct InstantiationArgs2 *p, uint32 v);
|
||||
|
||||
/* See wasm_export.h for description */
|
||||
WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *
|
||||
wasm_runtime_instantiate_ex2(WASMModuleCommon *module,
|
||||
const struct InstantiationArgs2 *args,
|
||||
char *error_buf, uint32 error_buf_size);
|
||||
|
||||
/* See wasm_export.h for description */
|
||||
WASM_RUNTIME_API_EXTERN bool
|
||||
wasm_runtime_set_running_mode(wasm_module_inst_t module_inst,
|
||||
|
|
|
@ -1316,6 +1316,13 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
|
|||
return false;
|
||||
break;
|
||||
|
||||
#if WASM_ENABLE_SIMD != 0
|
||||
case WASM_OP_SELECT_128:
|
||||
if (!aot_compile_op_select(comp_ctx, func_ctx, true))
|
||||
return false;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
|
||||
case WASM_OP_SELECT_T:
|
||||
{
|
||||
|
|
|
@ -289,8 +289,6 @@ typedef struct InstantiationArgs {
|
|||
} InstantiationArgs;
|
||||
#endif /* INSTANTIATION_ARGS_OPTION_DEFINED */
|
||||
|
||||
struct InstantiationArgs2;
|
||||
|
||||
#ifndef WASM_VALKIND_T_DEFINED
|
||||
#define WASM_VALKIND_T_DEFINED
|
||||
typedef uint8_t wasm_valkind_t;
|
||||
|
@ -735,46 +733,6 @@ wasm_runtime_instantiate_ex(const wasm_module_t module,
|
|||
const InstantiationArgs *args, char *error_buf,
|
||||
uint32_t error_buf_size);
|
||||
|
||||
/**
|
||||
* Create an InstantiationArgs2 object with default parameters.
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN bool
|
||||
wasm_runtime_instantiation_args_create(struct InstantiationArgs2 **p);
|
||||
|
||||
/**
|
||||
* Dispose an InstantiationArgs2 object.
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_instantiation_args_destroy(struct InstantiationArgs2 *p);
|
||||
|
||||
/**
|
||||
* Setter functions for the InstantiationArgs2 object.
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_instantiation_args_set_default_stack_size(
|
||||
struct InstantiationArgs2 *p, uint32_t v);
|
||||
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_instantiation_args_set_host_managed_heap_size(
|
||||
struct InstantiationArgs2 *p, uint32_t v);
|
||||
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_instantiation_args_set_max_memory_pages(
|
||||
struct InstantiationArgs2 *p, uint32_t v);
|
||||
|
||||
/**
|
||||
* Instantiate a WASM module, with specified instantiation arguments
|
||||
*
|
||||
* Same as wasm_runtime_instantiate_ex, but this version takes
|
||||
* InstantiationArgs2, which can be extended without breaking the ABI.
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN wasm_module_inst_t
|
||||
wasm_runtime_instantiate_ex2(const wasm_module_t module,
|
||||
const struct InstantiationArgs2 *args,
|
||||
char *error_buf, uint32_t error_buf_size);
|
||||
|
||||
/**
|
||||
* Set the running mode of a WASM module instance, override the
|
||||
* default running mode of the runtime. Note that it only makes sense when
|
||||
|
|
|
@ -1887,7 +1887,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
}
|
||||
HANDLE_OP_END();
|
||||
}
|
||||
#if WASM_ENABLE_SIMDE != 0
|
||||
#if WASM_ENABLE_SIMD != 0
|
||||
HANDLE_OP(WASM_OP_SELECT_128)
|
||||
{
|
||||
cond = frame_lp[GET_OFFSET()];
|
||||
|
|
|
@ -2303,14 +2303,9 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
|
|||
total_size = new_total_size;
|
||||
}
|
||||
|
||||
if (rec_count < 1) {
|
||||
LOG_VERBOSE("Processing 0-entry rec group");
|
||||
}
|
||||
else {
|
||||
LOG_VERBOSE("Processing rec group [%d-%d]",
|
||||
processed_type_count,
|
||||
processed_type_count + rec_count - 1);
|
||||
}
|
||||
LOG_VERBOSE("Processing rec group [%d-%d]",
|
||||
processed_type_count,
|
||||
processed_type_count + rec_count - 1);
|
||||
}
|
||||
else {
|
||||
p--;
|
||||
|
@ -2496,13 +2491,6 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
|
|||
#endif /* end of WASM_ENABLE_GC == 0 */
|
||||
}
|
||||
|
||||
for (i = 0; i < module->type_count; i++) {
|
||||
if (module->types[i] == NULL) {
|
||||
set_error_buf_v(error_buf, error_buf_size, "unknown type %d", i);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (p != p_end) {
|
||||
set_error_buf(error_buf, error_buf_size, "section size mismatch");
|
||||
return false;
|
||||
|
@ -7630,7 +7618,7 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
|
|||
case WASM_OP_SELECT:
|
||||
case WASM_OP_DROP_64:
|
||||
case WASM_OP_SELECT_64:
|
||||
#if WASM_ENABLE_SIMDE != 0
|
||||
#if WASM_ENABLE_FAST_INTERP != 0 && WASM_ENABLE_SIMD != 0
|
||||
case WASM_OP_SELECT_128:
|
||||
#endif
|
||||
break;
|
||||
|
@ -13155,7 +13143,9 @@ re_scan:
|
|||
#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) \
|
||||
|| (WASM_ENABLE_FAST_INTERP != 0)
|
||||
case VALUE_TYPE_V128:
|
||||
#if WASM_ENABLE_SIMDE != 0
|
||||
#if WASM_ENABLE_FAST_INTERP == 0
|
||||
*(p - 1) = WASM_OP_SELECT_128;
|
||||
#else
|
||||
if (loader_ctx->p_code_compiled) {
|
||||
uint8 opcode_tmp = WASM_OP_SELECT_128;
|
||||
#if WASM_ENABLE_LABELS_AS_VALUES != 0
|
||||
|
@ -13283,7 +13273,8 @@ re_scan:
|
|||
uint8 opcode_tmp = WASM_OP_SELECT;
|
||||
|
||||
if (type == VALUE_TYPE_V128) {
|
||||
#if WASM_ENABLE_SIMDE != 0
|
||||
#if WASM_ENABLE_JIT != 0 \
|
||||
|| WASM_ENABLE_FAST_INTERP != 0 && WASM_ENABLE_SIMD != 0
|
||||
opcode_tmp = WASM_OP_SELECT_128;
|
||||
#else
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
|
|
|
@ -278,7 +278,8 @@ typedef enum WASMOpcode {
|
|||
DEBUG_OP_BREAK = 0xdc, /* debug break point */
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_SIMDE != 0
|
||||
#if WASM_ENABLE_JIT != 0 || WASM_ENABLE_FAST_INTERP != 0 \
|
||||
|| WASM_ENABLE_WAMR_COMPILER != 0 && WASM_ENABLE_SIMD != 0
|
||||
EXT_OP_SET_LOCAL_FAST_V128 = 0xdd,
|
||||
EXT_OP_TEE_LOCAL_FAST_V128 = 0xde,
|
||||
EXT_OP_COPY_STACK_TOP_V128 = 0xdf,
|
||||
|
@ -797,7 +798,7 @@ typedef enum WASMAtomicEXTOpcode {
|
|||
#define SET_GOTO_TABLE_SIMD_PREFIX_ELEM()
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_SIMDE != 0
|
||||
#if WASM_ENABLE_SIMD != 0 && WASM_ENABLE_SIMDE != 0
|
||||
#define DEF_EXT_V128_HANDLE() \
|
||||
SET_GOTO_TABLE_ELEM(EXT_OP_SET_LOCAL_FAST_V128), /* 0xdd */ \
|
||||
SET_GOTO_TABLE_ELEM(EXT_OP_TEE_LOCAL_FAST_V128), /* 0xde */ \
|
||||
|
|
|
@ -135,28 +135,6 @@ typedef struct __wasi_addr_info_hints_t {
|
|||
#define IPV6_LEAVE_GROUP 21
|
||||
#define IPV6_V6ONLY 26
|
||||
|
||||
/* getaddrinfo error codes.
|
||||
*
|
||||
* we use values compatible with wasi-libc/musl netdb.h.
|
||||
* https://github.com/WebAssembly/wasi-libc/blob/4ea6fdfa288e15a57c02fe31dda78e5ddc87c3c7/libc-top-half/musl/include/netdb.h#L43-L53
|
||||
*
|
||||
* for now, non-posix error codes are excluded:
|
||||
* EAI_PROTOCOL and EAI_BADHINTS (BSDs)
|
||||
* EAI_ADDRFAMILY, EAI_NODATA
|
||||
* https://github.com/WebAssembly/wasi-libc/blob/4ea6fdfa288e15a57c02fe31dda78e5ddc87c3c7/libc-top-half/musl/include/netdb.h#L145-L152
|
||||
*/
|
||||
|
||||
#define EAI_AGAIN -3
|
||||
#define EAI_BADFLAGS -1
|
||||
#define EAI_FAIL -4
|
||||
#define EAI_FAMILY -6
|
||||
#define EAI_MEMORY -10
|
||||
#define EAI_NONAME -2
|
||||
#define EAI_OVERFLOW -12
|
||||
#define EAI_SERVICE -8
|
||||
#define EAI_SOCKTYPE -7
|
||||
#define EAI_SYSTEM -11
|
||||
|
||||
struct addrinfo {
|
||||
int ai_flags; /* Input flags. */
|
||||
int ai_family; /* Protocol family for socket. */
|
||||
|
@ -219,9 +197,6 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
|
|||
|
||||
void
|
||||
freeaddrinfo(struct addrinfo *res);
|
||||
|
||||
const char *
|
||||
gai_strerror(int code);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,13 +38,6 @@ __errno_location(void);
|
|||
return -1; \
|
||||
}
|
||||
|
||||
/* REVISIT: in many cases, EAI_SYSTEM may not be an ideal error code */
|
||||
#define GAI_HANDLE_ERROR(error) \
|
||||
if (error != __WASI_ERRNO_SUCCESS) { \
|
||||
errno = error; \
|
||||
return EAI_SYSTEM; \
|
||||
}
|
||||
|
||||
static void
|
||||
ipv4_addr_to_wasi_ip4_addr(uint32_t addr_num, __wasi_addr_ip4_t *out)
|
||||
{
|
||||
|
@ -198,7 +191,7 @@ bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
|
|||
error = __wasi_sock_bind(sockfd, &wasi_addr);
|
||||
HANDLE_ERROR(error)
|
||||
|
||||
return 0;
|
||||
return __WASI_ERRNO_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -219,7 +212,7 @@ connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
|
|||
error = __wasi_sock_connect(sockfd, &wasi_addr);
|
||||
HANDLE_ERROR(error)
|
||||
|
||||
return 0;
|
||||
return __WASI_ERRNO_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -227,7 +220,7 @@ listen(int sockfd, int backlog)
|
|||
{
|
||||
__wasi_errno_t error = __wasi_sock_listen(sockfd, backlog);
|
||||
HANDLE_ERROR(error)
|
||||
return 0;
|
||||
return __WASI_ERRNO_SUCCESS;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
|
@ -382,7 +375,7 @@ socket(int domain, int type, int protocol)
|
|||
af = INET6;
|
||||
}
|
||||
else {
|
||||
HANDLE_ERROR(__WASI_ERRNO_NOPROTOOPT)
|
||||
return __WASI_ERRNO_NOPROTOOPT;
|
||||
}
|
||||
|
||||
if (SOCK_DGRAM == type) {
|
||||
|
@ -392,7 +385,7 @@ socket(int domain, int type, int protocol)
|
|||
socktype = SOCKET_STREAM;
|
||||
}
|
||||
else {
|
||||
HANDLE_ERROR(__WASI_ERRNO_NOPROTOOPT)
|
||||
return __WASI_ERRNO_NOPROTOOPT;
|
||||
}
|
||||
|
||||
error = __wasi_sock_open(poolfd, af, socktype, &sockfd);
|
||||
|
@ -415,7 +408,7 @@ getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
|
|||
error = wasi_addr_to_sockaddr(&wasi_addr, addr, addrlen);
|
||||
HANDLE_ERROR(error)
|
||||
|
||||
return 0;
|
||||
return __WASI_ERRNO_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -432,7 +425,7 @@ getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
|
|||
error = wasi_addr_to_sockaddr(&wasi_addr, addr, addrlen);
|
||||
HANDLE_ERROR(error)
|
||||
|
||||
return 0;
|
||||
return __WASI_ERRNO_SUCCESS;
|
||||
}
|
||||
|
||||
struct aibuf {
|
||||
|
@ -525,7 +518,7 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
|
|||
struct aibuf *aibuf_res;
|
||||
|
||||
error = addrinfo_hints_to_wasi_hints(hints, &wasi_hints);
|
||||
GAI_HANDLE_ERROR(error)
|
||||
HANDLE_ERROR(error)
|
||||
|
||||
do {
|
||||
if (addr_info)
|
||||
|
@ -536,7 +529,7 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
|
|||
* sizeof(__wasi_addr_info_t));
|
||||
|
||||
if (!addr_info) {
|
||||
return EAI_MEMORY;
|
||||
HANDLE_ERROR(__WASI_ERRNO_NOMEM)
|
||||
}
|
||||
|
||||
error = __wasi_sock_addr_resolve(node, service == NULL ? "" : service,
|
||||
|
@ -544,25 +537,29 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
|
|||
&max_info_size);
|
||||
if (error != __WASI_ERRNO_SUCCESS) {
|
||||
free(addr_info);
|
||||
GAI_HANDLE_ERROR(error);
|
||||
HANDLE_ERROR(error);
|
||||
}
|
||||
} while (max_info_size > addr_info_size);
|
||||
|
||||
addr_info_size = max_info_size;
|
||||
if (addr_info_size == 0) {
|
||||
free(addr_info);
|
||||
return EAI_NONAME;
|
||||
*res = NULL;
|
||||
return __WASI_ERRNO_SUCCESS;
|
||||
}
|
||||
|
||||
aibuf_res =
|
||||
(struct aibuf *)calloc(1, addr_info_size * sizeof(struct aibuf));
|
||||
if (!aibuf_res) {
|
||||
free(addr_info);
|
||||
return EAI_MEMORY;
|
||||
HANDLE_ERROR(__WASI_ERRNO_NOMEM)
|
||||
}
|
||||
|
||||
*res = &aibuf_res[0].ai;
|
||||
|
||||
if (addr_info_size) {
|
||||
addr_info_size = max_info_size;
|
||||
}
|
||||
|
||||
for (i = 0; i < addr_info_size; i++) {
|
||||
struct addrinfo *ai = &aibuf_res[i].ai;
|
||||
ai->ai_addr = (struct sockaddr *)&aibuf_res[i].sa;
|
||||
|
@ -571,14 +568,14 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
|
|||
if (error != __WASI_ERRNO_SUCCESS) {
|
||||
free(addr_info);
|
||||
free(aibuf_res);
|
||||
GAI_HANDLE_ERROR(error)
|
||||
HANDLE_ERROR(error)
|
||||
}
|
||||
ai->ai_next = i == addr_info_size - 1 ? NULL : &aibuf_res[i + 1].ai;
|
||||
}
|
||||
|
||||
free(addr_info);
|
||||
|
||||
return 0;
|
||||
return __WASI_ERRNO_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -590,28 +587,6 @@ freeaddrinfo(struct addrinfo *res)
|
|||
free(res);
|
||||
}
|
||||
|
||||
const char *
|
||||
gai_strerror(int code)
|
||||
{
|
||||
switch (code) {
|
||||
#define ERR(a) \
|
||||
case a: \
|
||||
return #a
|
||||
ERR(EAI_AGAIN);
|
||||
ERR(EAI_BADFLAGS);
|
||||
ERR(EAI_FAIL);
|
||||
ERR(EAI_FAMILY);
|
||||
ERR(EAI_MEMORY);
|
||||
ERR(EAI_NONAME);
|
||||
ERR(EAI_OVERFLOW);
|
||||
ERR(EAI_SERVICE);
|
||||
ERR(EAI_SOCKTYPE);
|
||||
ERR(EAI_SYSTEM);
|
||||
#undef ERR
|
||||
}
|
||||
return "Unknown error";
|
||||
}
|
||||
|
||||
static struct timeval
|
||||
time_us_to_timeval(uint64_t time_us)
|
||||
{
|
||||
|
@ -635,7 +610,6 @@ get_sol_socket_option(int sockfd, int optname, void *__restrict optval,
|
|||
uint64_t timeout_us;
|
||||
bool is_linger_enabled;
|
||||
int linger_s;
|
||||
__wasi_fdstat_t sb;
|
||||
|
||||
switch (optname) {
|
||||
case SO_RCVTIMEO:
|
||||
|
@ -643,38 +617,38 @@ get_sol_socket_option(int sockfd, int optname, void *__restrict optval,
|
|||
error = __wasi_sock_get_recv_timeout(sockfd, &timeout_us);
|
||||
HANDLE_ERROR(error);
|
||||
*(struct timeval *)optval = time_us_to_timeval(timeout_us);
|
||||
return 0;
|
||||
return error;
|
||||
case SO_SNDTIMEO:
|
||||
assert(*optlen == sizeof(struct timeval));
|
||||
error = __wasi_sock_get_send_timeout(sockfd, &timeout_us);
|
||||
HANDLE_ERROR(error);
|
||||
*(struct timeval *)optval = time_us_to_timeval(timeout_us);
|
||||
return 0;
|
||||
return error;
|
||||
case SO_SNDBUF:
|
||||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_sock_get_send_buf_size(sockfd, (size_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case SO_RCVBUF:
|
||||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_sock_get_recv_buf_size(sockfd, (size_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case SO_KEEPALIVE:
|
||||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_sock_get_keep_alive(sockfd, (bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case SO_REUSEADDR:
|
||||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_sock_get_reuse_addr(sockfd, (bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case SO_REUSEPORT:
|
||||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_sock_get_reuse_port(sockfd, (bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case SO_LINGER:
|
||||
assert(*optlen == sizeof(struct linger));
|
||||
error =
|
||||
|
@ -682,32 +656,16 @@ get_sol_socket_option(int sockfd, int optname, void *__restrict optval,
|
|||
HANDLE_ERROR(error);
|
||||
((struct linger *)optval)->l_onoff = (int)is_linger_enabled;
|
||||
((struct linger *)optval)->l_linger = linger_s;
|
||||
return 0;
|
||||
return error;
|
||||
case SO_BROADCAST:
|
||||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_sock_get_broadcast(sockfd, (bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
case SO_TYPE:
|
||||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_fd_fdstat_get(sockfd, &sb);
|
||||
HANDLE_ERROR(error);
|
||||
switch (sb.fs_filetype) {
|
||||
case __WASI_FILETYPE_SOCKET_DGRAM:
|
||||
*(int *)optval = SOCK_DGRAM;
|
||||
break;
|
||||
case __WASI_FILETYPE_SOCKET_STREAM:
|
||||
*(int *)optval = SOCK_STREAM;
|
||||
break;
|
||||
default:
|
||||
errno = __WASI_ERRNO_NOTSOCK;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
return error;
|
||||
default:
|
||||
error = __WASI_ERRNO_NOTSUP;
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -721,32 +679,32 @@ get_ipproto_tcp_option(int sockfd, int optname, void *__restrict optval,
|
|||
assert(*optlen == sizeof(uint32_t));
|
||||
error = __wasi_sock_get_tcp_keep_idle(sockfd, (uint32_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case TCP_KEEPINTVL:
|
||||
assert(*optlen == sizeof(uint32_t));
|
||||
error = __wasi_sock_get_tcp_keep_intvl(sockfd, (uint32_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case TCP_FASTOPEN_CONNECT:
|
||||
assert(*optlen == sizeof(int));
|
||||
error =
|
||||
__wasi_sock_get_tcp_fastopen_connect(sockfd, (bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case TCP_NODELAY:
|
||||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_sock_get_tcp_no_delay(sockfd, (bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case TCP_QUICKACK:
|
||||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_sock_get_tcp_quick_ack(sockfd, (bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
default:
|
||||
error = __WASI_ERRNO_NOTSUP;
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -762,21 +720,21 @@ get_ipproto_ip_option(int sockfd, int optname, void *__restrict optval,
|
|||
error = __wasi_sock_get_ip_multicast_loop(sockfd, false,
|
||||
(bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case IP_TTL:
|
||||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_sock_get_ip_ttl(sockfd, (uint8_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case IP_MULTICAST_TTL:
|
||||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_sock_get_ip_multicast_ttl(sockfd, (uint8_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
default:
|
||||
error = __WASI_ERRNO_NOTSUP;
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -791,17 +749,17 @@ get_ipproto_ipv6_option(int sockfd, int optname, void *__restrict optval,
|
|||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_sock_get_ipv6_only(sockfd, (bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case IPV6_MULTICAST_LOOP:
|
||||
assert(*optlen == sizeof(int));
|
||||
error =
|
||||
__wasi_sock_get_ip_multicast_loop(sockfd, true, (bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
default:
|
||||
error = __WASI_ERRNO_NOTSUP;
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -823,7 +781,7 @@ getsockopt(int sockfd, int level, int optname, void *__restrict optval,
|
|||
default:
|
||||
error = __WASI_ERRNO_NOTSUP;
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -841,7 +799,7 @@ set_sol_socket_option(int sockfd, int optname, const void *optval,
|
|||
timeout_us = timeval_to_time_us(*(struct timeval *)optval);
|
||||
error = __wasi_sock_set_recv_timeout(sockfd, timeout_us);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
case SO_SNDTIMEO:
|
||||
{
|
||||
|
@ -849,42 +807,42 @@ set_sol_socket_option(int sockfd, int optname, const void *optval,
|
|||
timeout_us = timeval_to_time_us(*(struct timeval *)optval);
|
||||
error = __wasi_sock_set_send_timeout(sockfd, timeout_us);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
case SO_SNDBUF:
|
||||
{
|
||||
assert(optlen == sizeof(int));
|
||||
error = __wasi_sock_set_send_buf_size(sockfd, *(size_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
case SO_RCVBUF:
|
||||
{
|
||||
assert(optlen == sizeof(int));
|
||||
error = __wasi_sock_set_recv_buf_size(sockfd, *(size_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
case SO_KEEPALIVE:
|
||||
{
|
||||
assert(optlen == sizeof(int));
|
||||
error = __wasi_sock_set_keep_alive(sockfd, *(bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
case SO_REUSEADDR:
|
||||
{
|
||||
assert(optlen == sizeof(int));
|
||||
error = __wasi_sock_set_reuse_addr(sockfd, *(bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
case SO_REUSEPORT:
|
||||
{
|
||||
assert(optlen == sizeof(int));
|
||||
error = __wasi_sock_set_reuse_port(sockfd, *(bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
case SO_LINGER:
|
||||
{
|
||||
|
@ -893,20 +851,20 @@ set_sol_socket_option(int sockfd, int optname, const void *optval,
|
|||
error = __wasi_sock_set_linger(sockfd, (bool)linger_opt->l_onoff,
|
||||
linger_opt->l_linger);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
case SO_BROADCAST:
|
||||
{
|
||||
assert(optlen == sizeof(int));
|
||||
error = __wasi_sock_set_broadcast(sockfd, *(bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
default:
|
||||
{
|
||||
error = __WASI_ERRNO_NOTSUP;
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -922,32 +880,32 @@ set_ipproto_tcp_option(int sockfd, int optname, const void *optval,
|
|||
assert(optlen == sizeof(int));
|
||||
error = __wasi_sock_set_tcp_no_delay(sockfd, *(bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case TCP_KEEPIDLE:
|
||||
assert(optlen == sizeof(uint32_t));
|
||||
error = __wasi_sock_set_tcp_keep_idle(sockfd, *(uint32_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case TCP_KEEPINTVL:
|
||||
assert(optlen == sizeof(uint32_t));
|
||||
error = __wasi_sock_set_tcp_keep_intvl(sockfd, *(uint32_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case TCP_FASTOPEN_CONNECT:
|
||||
assert(optlen == sizeof(int));
|
||||
error =
|
||||
__wasi_sock_set_tcp_fastopen_connect(sockfd, *(bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case TCP_QUICKACK:
|
||||
assert(optlen == sizeof(int));
|
||||
error = __wasi_sock_set_tcp_quick_ack(sockfd, *(bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
default:
|
||||
error = __WASI_ERRNO_NOTSUP;
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -965,7 +923,7 @@ set_ipproto_ip_option(int sockfd, int optname, const void *optval,
|
|||
error = __wasi_sock_set_ip_multicast_loop(sockfd, false,
|
||||
*(bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case IP_ADD_MEMBERSHIP:
|
||||
assert(optlen == sizeof(struct ip_mreq));
|
||||
ip_mreq_opt = (struct ip_mreq *)optval;
|
||||
|
@ -975,7 +933,7 @@ set_ipproto_ip_option(int sockfd, int optname, const void *optval,
|
|||
error = __wasi_sock_set_ip_add_membership(
|
||||
sockfd, &imr_multiaddr, ip_mreq_opt->imr_interface.s_addr);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case IP_DROP_MEMBERSHIP:
|
||||
assert(optlen == sizeof(struct ip_mreq));
|
||||
ip_mreq_opt = (struct ip_mreq *)optval;
|
||||
|
@ -985,22 +943,22 @@ set_ipproto_ip_option(int sockfd, int optname, const void *optval,
|
|||
error = __wasi_sock_set_ip_drop_membership(
|
||||
sockfd, &imr_multiaddr, ip_mreq_opt->imr_interface.s_addr);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case IP_TTL:
|
||||
assert(optlen == sizeof(int));
|
||||
error = __wasi_sock_set_ip_ttl(sockfd, *(uint8_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case IP_MULTICAST_TTL:
|
||||
assert(optlen == sizeof(int));
|
||||
error =
|
||||
__wasi_sock_set_ip_multicast_ttl(sockfd, *(uint8_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
default:
|
||||
error = __WASI_ERRNO_NOTSUP;
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1017,13 +975,13 @@ set_ipproto_ipv6_option(int sockfd, int optname, const void *optval,
|
|||
assert(optlen == sizeof(int));
|
||||
error = __wasi_sock_set_ipv6_only(sockfd, *(bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case IPV6_MULTICAST_LOOP:
|
||||
assert(optlen == sizeof(int));
|
||||
error = __wasi_sock_set_ip_multicast_loop(sockfd, true,
|
||||
*(bool *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case IPV6_JOIN_GROUP:
|
||||
assert(optlen == sizeof(struct ipv6_mreq));
|
||||
ipv6_mreq_opt = (struct ipv6_mreq *)optval;
|
||||
|
@ -1034,7 +992,7 @@ set_ipproto_ipv6_option(int sockfd, int optname, const void *optval,
|
|||
error = __wasi_sock_set_ip_add_membership(
|
||||
sockfd, &imr_multiaddr, ipv6_mreq_opt->ipv6mr_interface);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
case IPV6_LEAVE_GROUP:
|
||||
assert(optlen == sizeof(struct ipv6_mreq));
|
||||
ipv6_mreq_opt = (struct ipv6_mreq *)optval;
|
||||
|
@ -1045,11 +1003,11 @@ set_ipproto_ipv6_option(int sockfd, int optname, const void *optval,
|
|||
error = __wasi_sock_set_ip_drop_membership(
|
||||
sockfd, &imr_multiaddr, ipv6_mreq_opt->ipv6mr_interface);
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
default:
|
||||
error = __WASI_ERRNO_NOTSUP;
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1071,6 +1029,6 @@ setsockopt(int sockfd, int level, int optname, const void *optval,
|
|||
default:
|
||||
error = __WASI_ERRNO_NOTSUP;
|
||||
HANDLE_ERROR(error);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -507,35 +507,10 @@ fail:
|
|||
return res;
|
||||
}
|
||||
|
||||
static wasi_nn_error
|
||||
copyin_and_nul_terminate(wasm_module_inst_t inst, char *name, uint32_t name_len,
|
||||
char **resultp)
|
||||
{
|
||||
char *nul_terminated_name;
|
||||
if (!wasm_runtime_validate_native_addr(inst, name, name_len)) {
|
||||
return invalid_argument;
|
||||
}
|
||||
nul_terminated_name = wasm_runtime_malloc(name_len + 1);
|
||||
if (nul_terminated_name == NULL) {
|
||||
return runtime_error;
|
||||
}
|
||||
bh_memcpy_s(nul_terminated_name, name_len + 1, name, name_len);
|
||||
nul_terminated_name[name_len] = '\0'; /* ensure NUL termination */
|
||||
if (strlen(nul_terminated_name) != name_len) {
|
||||
/* reject names containing '\0' for now */
|
||||
wasm_runtime_free(nul_terminated_name);
|
||||
return invalid_argument;
|
||||
}
|
||||
*resultp = nul_terminated_name;
|
||||
return success;
|
||||
}
|
||||
|
||||
wasi_nn_error
|
||||
wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
|
||||
graph *g)
|
||||
{
|
||||
WASINNContext *wasi_nn_ctx = NULL;
|
||||
char *nul_terminated_name = NULL;
|
||||
wasi_nn_error res;
|
||||
|
||||
wasm_module_inst_t instance = wasm_runtime_get_module_inst(exec_env);
|
||||
|
@ -543,21 +518,25 @@ wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
|
|||
return runtime_error;
|
||||
}
|
||||
|
||||
if (!wasm_runtime_validate_native_addr(instance, name, name_len)) {
|
||||
NN_ERR_PRINTF("name is invalid");
|
||||
return invalid_argument;
|
||||
}
|
||||
|
||||
if (!wasm_runtime_validate_native_addr(instance, g,
|
||||
(uint64)sizeof(graph))) {
|
||||
NN_ERR_PRINTF("graph is invalid");
|
||||
return invalid_argument;
|
||||
}
|
||||
|
||||
res = copyin_and_nul_terminate(instance, name, name_len,
|
||||
&nul_terminated_name);
|
||||
if (res != success) {
|
||||
goto fail;
|
||||
if (name_len == 0 || name[name_len] != '\0') {
|
||||
NN_ERR_PRINTF("Invalid filename");
|
||||
return invalid_argument;
|
||||
}
|
||||
|
||||
NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME %s...", nul_terminated_name);
|
||||
NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME %s...", name);
|
||||
|
||||
wasi_nn_ctx = lock_ctx(instance);
|
||||
WASINNContext *wasi_nn_ctx = lock_ctx(instance);
|
||||
if (wasi_nn_ctx == NULL) {
|
||||
res = busy;
|
||||
goto fail;
|
||||
|
@ -568,20 +547,14 @@ wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
|
|||
goto fail;
|
||||
|
||||
call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name, res,
|
||||
wasi_nn_ctx->backend_ctx, nul_terminated_name, name_len,
|
||||
g);
|
||||
wasi_nn_ctx->backend_ctx, name, name_len, g);
|
||||
if (res != success)
|
||||
goto fail;
|
||||
|
||||
wasi_nn_ctx->is_model_loaded = true;
|
||||
res = success;
|
||||
fail:
|
||||
if (nul_terminated_name != NULL) {
|
||||
wasm_runtime_free(nul_terminated_name);
|
||||
}
|
||||
if (wasi_nn_ctx != NULL) {
|
||||
unlock_ctx(wasi_nn_ctx);
|
||||
}
|
||||
unlock_ctx(wasi_nn_ctx);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -590,9 +563,6 @@ wasi_nn_load_by_name_with_config(wasm_exec_env_t exec_env, char *name,
|
|||
int32_t name_len, char *config,
|
||||
int32_t config_len, graph *g)
|
||||
{
|
||||
WASINNContext *wasi_nn_ctx = NULL;
|
||||
char *nul_terminated_name = NULL;
|
||||
char *nul_terminated_config = NULL;
|
||||
wasi_nn_error res;
|
||||
|
||||
wasm_module_inst_t instance = wasm_runtime_get_module_inst(exec_env);
|
||||
|
@ -600,27 +570,30 @@ wasi_nn_load_by_name_with_config(wasm_exec_env_t exec_env, char *name,
|
|||
return runtime_error;
|
||||
}
|
||||
|
||||
if (!wasm_runtime_validate_native_addr(instance, name, name_len)) {
|
||||
NN_ERR_PRINTF("name is invalid");
|
||||
return invalid_argument;
|
||||
}
|
||||
|
||||
if (!wasm_runtime_validate_native_addr(instance, g,
|
||||
(uint64)sizeof(graph))) {
|
||||
NN_ERR_PRINTF("graph is invalid");
|
||||
return invalid_argument;
|
||||
}
|
||||
|
||||
res = copyin_and_nul_terminate(instance, name, name_len,
|
||||
&nul_terminated_name);
|
||||
if (res != success) {
|
||||
goto fail;
|
||||
}
|
||||
res = copyin_and_nul_terminate(instance, config, config_len,
|
||||
&nul_terminated_config);
|
||||
if (res != success) {
|
||||
goto fail;
|
||||
if (name_len == 0 || name[name_len] != '\0') {
|
||||
NN_ERR_PRINTF("Invalid filename");
|
||||
return invalid_argument;
|
||||
}
|
||||
|
||||
NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME_WITH_CONFIG %s %s...",
|
||||
nul_terminated_name, nul_terminated_config);
|
||||
if (!config || config_len == 0 || config[config_len] != '\0') {
|
||||
NN_ERR_PRINTF("Invalid config");
|
||||
return invalid_argument;
|
||||
}
|
||||
|
||||
wasi_nn_ctx = lock_ctx(instance);
|
||||
NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME_WITH_CONFIG %s %s...", name, config);
|
||||
|
||||
WASINNContext *wasi_nn_ctx = lock_ctx(instance);
|
||||
if (wasi_nn_ctx == NULL) {
|
||||
res = busy;
|
||||
goto fail;
|
||||
|
@ -632,23 +605,15 @@ wasi_nn_load_by_name_with_config(wasm_exec_env_t exec_env, char *name,
|
|||
;
|
||||
|
||||
call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name_with_config, res,
|
||||
wasi_nn_ctx->backend_ctx, nul_terminated_name, name_len,
|
||||
nul_terminated_config, config_len, g);
|
||||
wasi_nn_ctx->backend_ctx, name, name_len, config,
|
||||
config_len, g);
|
||||
if (res != success)
|
||||
goto fail;
|
||||
|
||||
wasi_nn_ctx->is_model_loaded = true;
|
||||
res = success;
|
||||
fail:
|
||||
if (nul_terminated_name != NULL) {
|
||||
wasm_runtime_free(nul_terminated_name);
|
||||
}
|
||||
if (nul_terminated_config != NULL) {
|
||||
wasm_runtime_free(nul_terminated_config);
|
||||
}
|
||||
if (wasi_nn_ctx != NULL) {
|
||||
unlock_ctx(wasi_nn_ctx);
|
||||
}
|
||||
unlock_ctx(wasi_nn_ctx);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -815,12 +780,6 @@ static NativeSymbol native_symbols_wasi_nn[] = {
|
|||
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
|
||||
REG_NATIVE_FUNC(load, "(*iii*)i"),
|
||||
REG_NATIVE_FUNC(load_by_name, "(*i*)i"),
|
||||
|
||||
/* load_by_name_with_config is intented to be compatible with
|
||||
* a wasmedge extension.
|
||||
* https://github.com/second-state/wasmedge-wasi-nn/pull/2
|
||||
* https://github.com/WasmEdge/WasmEdge/blob/5553924e8cdccdc2cbd2a6a6d0ed9b11250c353e/plugins/wasi_nn/wasinnmodule.cpp#L13-L14
|
||||
*/
|
||||
REG_NATIVE_FUNC(load_by_name_with_config, "(*i*i*)i"),
|
||||
REG_NATIVE_FUNC(init_execution_context, "(i*)i"),
|
||||
REG_NATIVE_FUNC(set_input, "(ii*)i"),
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "wasi_nn_backend.h"
|
||||
#include "wasm_export.h"
|
||||
|
||||
#include <tensorflow/lite/c/c_api.h>
|
||||
#include <tensorflow/lite/interpreter.h>
|
||||
#include <tensorflow/lite/kernels/register.h>
|
||||
#include <tensorflow/lite/model.h>
|
||||
|
@ -280,53 +279,29 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
|
|||
tensor *input_tensor)
|
||||
{
|
||||
TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx;
|
||||
TfLiteType tfl_type;
|
||||
|
||||
switch (input_tensor->type) {
|
||||
case fp32:
|
||||
tfl_type = TfLiteType::kTfLiteFloat32;
|
||||
break;
|
||||
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
|
||||
case u8:
|
||||
tfl_type = TfLiteType::kTfLiteUInt8;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
NN_ERR_PRINTF("unsupported input tensor type %u",
|
||||
input_tensor->type);
|
||||
return runtime_error;
|
||||
if (input_tensor->type != fp32) {
|
||||
NN_ERR_PRINTF("unsupported input tensor type %u", input_tensor->type);
|
||||
return runtime_error;
|
||||
}
|
||||
|
||||
wasi_nn_error res;
|
||||
if (success != (res = is_valid_graph_execution_context(tfl_ctx, ctx)))
|
||||
return res;
|
||||
|
||||
auto interpreter = tfl_ctx->interpreters[ctx].interpreter.get();
|
||||
|
||||
uint32_t num_tensors = interpreter->inputs().size();
|
||||
uint32_t num_tensors =
|
||||
tfl_ctx->interpreters[ctx].interpreter->inputs().size();
|
||||
NN_DBG_PRINTF("Number of tensors (%d)", num_tensors);
|
||||
if (index + 1 > num_tensors) {
|
||||
return runtime_error;
|
||||
}
|
||||
|
||||
auto tensor = interpreter->input_tensor(index);
|
||||
auto tensor = tfl_ctx->interpreters[ctx].interpreter->input_tensor(index);
|
||||
if (tensor == NULL) {
|
||||
NN_ERR_PRINTF("Missing memory");
|
||||
return too_large;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
|
||||
if (TfLiteTensorType(tensor) != tfl_type) {
|
||||
NN_ERR_PRINTF("Type mismatch");
|
||||
return runtime_error;
|
||||
}
|
||||
|
||||
if (TfLiteTensorCopyFromBuffer(tensor, input_tensor->data.buf,
|
||||
input_tensor->data.size)
|
||||
!= kTfLiteOk) {
|
||||
return runtime_error;
|
||||
}
|
||||
#else
|
||||
uint32_t model_tensor_size = 1;
|
||||
for (int i = 0; i < tensor->dims->size; ++i)
|
||||
model_tensor_size *= (uint32_t)tensor->dims->data[i];
|
||||
|
@ -371,7 +346,6 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
|
|||
it[i] = (uint8_t)(input_tensor_f[i] / scale + zero_point);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -414,19 +388,14 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
|
|||
return too_large;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
|
||||
size_t sz = TfLiteTensorByteSize(tensor);
|
||||
if (output_tensor->size < sz) {
|
||||
NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index);
|
||||
return too_large;
|
||||
}
|
||||
if (TfLiteTensorCopyToBuffer(tensor, output_tensor->buf, sz) != kTfLiteOk) {
|
||||
return runtime_error;
|
||||
}
|
||||
*output_tensor_size = sz;
|
||||
#else
|
||||
if (tensor->quantization.type == kTfLiteNoQuantization) {
|
||||
NN_DBG_PRINTF("No quantization information");
|
||||
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
|
||||
if (output_tensor->size < tensor->bytes) {
|
||||
NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index);
|
||||
return too_large;
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* for now, maintain the bug-to-bug compatibility with the old abi,
|
||||
* where the size here is the number of fp32, not bytes.
|
||||
|
@ -435,13 +404,18 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
|
|||
NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index);
|
||||
return too_large;
|
||||
}
|
||||
#endif
|
||||
bh_memcpy_s(output_tensor->buf, output_tensor->size, tensor->data.data,
|
||||
tensor->bytes);
|
||||
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
|
||||
*output_tensor_size = tensor->bytes;
|
||||
#else
|
||||
/*
|
||||
* for now, maintain the bug-to-bug compatibility with the old abi,
|
||||
* where the size here is the number of fp32, not bytes.
|
||||
*/
|
||||
*output_tensor_size = tensor->bytes / sizeof(float);
|
||||
#endif
|
||||
}
|
||||
else { // TODO: Assuming uint8 quantized networks.
|
||||
TfLiteAffineQuantization *quant_info =
|
||||
|
@ -455,6 +429,12 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
|
|||
for (int i = 0; i < (int)tensor->dims->size; ++i)
|
||||
model_tensor_size *= (uint32_t)tensor->dims->data[i];
|
||||
|
||||
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
|
||||
if (output_tensor->size / sizeof(float) < model_tensor_size) {
|
||||
NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index);
|
||||
return too_large;
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* for now, maintain the bug-to-bug compatibility with the old abi,
|
||||
* where the size here is the number of fp32, not bytes.
|
||||
|
@ -463,6 +443,7 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
|
|||
NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index);
|
||||
return too_large;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t *ot = tfl_ctx->interpreters[ctx]
|
||||
.interpreter->typed_output_tensor<uint8_t>(index);
|
||||
|
@ -477,13 +458,16 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
|
|||
output_tensor_f[i] = (ot[i] - zero_point) * scale;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
|
||||
*output_tensor_size = model_tensor_size * sizeof(float);
|
||||
#else
|
||||
/*
|
||||
* for now, maintain the bug-to-bug compatibility with the old abi,
|
||||
* where the size here is the number of fp32, not bytes.
|
||||
*/
|
||||
*output_tensor_size = model_tensor_size;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -220,17 +220,12 @@ int
|
|||
os_socket_accept(bh_socket_t server_sock, bh_socket_t *sock, void *addr,
|
||||
unsigned int *addrlen)
|
||||
{
|
||||
if (addr == NULL) {
|
||||
*sock = accept(server_sock, NULL, NULL);
|
||||
}
|
||||
else {
|
||||
socklen_t len = *addrlen;
|
||||
*sock = accept(server_sock, addr, &len);
|
||||
*addrlen = len;
|
||||
}
|
||||
*sock = accept(server_sock, addr, addrlen);
|
||||
|
||||
if (*sock < 0) {
|
||||
return BHT_ERROR;
|
||||
}
|
||||
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
|
@ -378,8 +373,8 @@ is_addrinfo_supported(struct addrinfo *info)
|
|||
(info->ai_family == AF_INET || info->ai_family == AF_INET6)
|
||||
// Allow only UDP and TCP
|
||||
&& (info->ai_socktype == SOCK_DGRAM || info->ai_socktype == SOCK_STREAM)
|
||||
&& (info->ai_protocol == IPPROTO_TCP || info->ai_protocol == IPPROTO_UDP
|
||||
|| info->ai_protocol == 0);
|
||||
&& (info->ai_protocol == IPPROTO_TCP
|
||||
|| info->ai_protocol == IPPROTO_UDP);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -110,13 +110,6 @@ os_thread_create_with_prio(korp_tid *tid, thread_start_routine_t start,
|
|||
targ->start = start;
|
||||
targ->arg = arg;
|
||||
|
||||
#ifdef CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM
|
||||
esp_pthread_cfg_t default_config = esp_pthread_get_default_config();
|
||||
|
||||
default_config.stack_alloc_caps = MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM;
|
||||
ESP_ERROR_CHECK(esp_pthread_set_cfg(&default_config));
|
||||
#endif
|
||||
|
||||
if (pthread_create(tid, &tattr, os_thread_wrapper, targ) != 0) {
|
||||
pthread_attr_destroy(&tattr);
|
||||
os_free(targ);
|
||||
|
|
|
@ -59,7 +59,7 @@ b_memcpy_wa(void *s1, unsigned int s1max, const void *s2, unsigned int n)
|
|||
*dest++ = *p_byte_read++;
|
||||
}
|
||||
}
|
||||
/* read remaining word(s) */
|
||||
/* read meaning word(s) */
|
||||
else {
|
||||
if ((char *)p + 4 >= src + n) {
|
||||
for (ps = (char *)p; ps < src + n; ps++) {
|
||||
|
|
|
@ -170,7 +170,7 @@ bh_free_msg(bh_queue_node *msg)
|
|||
return;
|
||||
}
|
||||
|
||||
// note: sometimes we just use the payload pointer for an integer value
|
||||
// note: sometime we just use the payload pointer for a integer value
|
||||
// len!=0 is the only indicator about the body is an allocated buffer.
|
||||
if (msg->body && msg->len)
|
||||
bh_queue_free(msg->body);
|
||||
|
|
|
@ -44,22 +44,22 @@ bh_get_tick_ms()
|
|||
uint32
|
||||
bh_get_elpased_ms(uint32 *last_system_clock)
|
||||
{
|
||||
uint32 elapsed_ms;
|
||||
/* attention: the bh_get_tick_ms() returns a 64-bit integer, but
|
||||
bh_get_elpased_ms() is designed to use a 32-bit clock count */
|
||||
uint32 elpased_ms;
|
||||
/* attention: the bh_get_tick_ms() return 64 bits integer, but
|
||||
the bh_get_elpased_ms() is designed to use 32 bits clock count */
|
||||
uint32 now = (uint32)bh_get_tick_ms();
|
||||
|
||||
/* system clock overrun */
|
||||
if (now < *last_system_clock) {
|
||||
PRINT("system clock overrun!\n");
|
||||
elapsed_ms = now + (UINT32_MAX - *last_system_clock) + 1;
|
||||
elpased_ms = now + (UINT32_MAX - *last_system_clock) + 1;
|
||||
}
|
||||
else {
|
||||
elapsed_ms = now - *last_system_clock;
|
||||
elpased_ms = now - *last_system_clock;
|
||||
}
|
||||
|
||||
*last_system_clock = now;
|
||||
return elapsed_ms;
|
||||
return elpased_ms;
|
||||
}
|
||||
|
||||
static app_timer_t *
|
||||
|
@ -162,7 +162,7 @@ reschedule_timer(timer_ctx_t ctx, app_timer_t *timer)
|
|||
prev->id);
|
||||
}
|
||||
else {
|
||||
/* insert at the beginning */
|
||||
/* insert at the begin */
|
||||
bh_assert(ctx->app_timers == NULL);
|
||||
ctx->app_timers = timer;
|
||||
PRINT("rescheduled timer [%d] as first\n", timer->id);
|
||||
|
@ -213,7 +213,7 @@ release_timer_list(app_timer_t **p_list)
|
|||
|
||||
timer_ctx_t
|
||||
create_timer_ctx(timer_callback_f timer_handler,
|
||||
check_timer_expiry_f expiry_checker, int prealloc_num,
|
||||
check_timer_expiry_f expiery_checker, int prealloc_num,
|
||||
unsigned int owner)
|
||||
{
|
||||
timer_ctx_t ctx = (timer_ctx_t)BH_MALLOC(sizeof(struct _timer_ctx));
|
||||
|
@ -225,7 +225,7 @@ create_timer_ctx(timer_callback_f timer_handler,
|
|||
|
||||
ctx->timer_callback = timer_handler;
|
||||
ctx->pre_allocated = prealloc_num;
|
||||
ctx->refresh_checker = expiry_checker;
|
||||
ctx->refresh_checker = expiery_checker;
|
||||
ctx->owner = owner;
|
||||
|
||||
while (prealloc_num > 0) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
/* clang-format off */
|
||||
#define WAMR_VERSION_MAJOR 2
|
||||
#define WAMR_VERSION_MINOR 4
|
||||
#define WAMR_VERSION_PATCH 1
|
||||
#define WAMR_VERSION_PATCH 0
|
||||
/* clang-format on */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -382,26 +382,17 @@ a non-compatible`AOT_CURRENT_VERSION`.
|
|||
We try our best to maintain our runtime ABI for AoT-compiled modules
|
||||
compatible among WAMR versions with compatible `AOT_CURRENT_VERSION`
|
||||
so that combinations of older wamrc and newer runtime usually work.
|
||||
However, there might be minor incompatibilities time to time.
|
||||
For productions, we recommend to use compatible versions of
|
||||
wamrc and the runtime.
|
||||
|
||||
However, there might be minor incompatibilities from time to time. For
|
||||
example, we usually avoid bumping the version when making a change which
|
||||
affects only a small fraction of users. For productions, we recommend
|
||||
using exactly same versions of wamrc and the runtime.
|
||||
|
||||
| WAMR version | AOT_CURRENT_VERSION | Compatible AOT version | |
|
||||
| ------------ | ------------------- | ---------------------- | ---------------------- |
|
||||
| 1.x | 3 | 3 | |
|
||||
| 2.0.0 | 3 | 3 | |
|
||||
| 2.1.x | 3 | 3 | |
|
||||
| 2.2.0 | 3 | 3 | |
|
||||
| 2.3.0 | 4 | 3,4 | |
|
||||
| 2.4.0 | 4 | 3,4 | See the following note |
|
||||
| 2.4.1 | 5 | 5 | |
|
||||
|
||||
Note: 2.4.0 had a broken AoT versioning. See [issue 4504] for details.
|
||||
We recommend all 2.4.0 users to migrate to 2.4.1.
|
||||
|
||||
[issue 4504]: https://github.com/bytecodealliance/wasm-micro-runtime/issues/4504
|
||||
| WAMR version | AOT_CURRENT_VERSION | Compatible AOT version |
|
||||
| ------------ | ------------------- | ---------------------- |
|
||||
| 1.x | 3 | 3 |
|
||||
| 2.0.0 | 3 | 3 |
|
||||
| 2.1.x | 3 | 3 |
|
||||
| 2.2.0 | 3 | 3 |
|
||||
| next | 4 | 3,4 |
|
||||
|
||||
## AoT compilation with 3rd-party toolchains
|
||||
|
||||
|
|
|
@ -58,8 +58,7 @@ enabled.
|
|||
|
||||
_iwasm_ accepts address ranges via an option, `--addr-pool`, to implement
|
||||
the capability control. All IP address the WebAssembly application may need to `bind()` or `connect()`
|
||||
should be announced first. Every IP address should be in CIDR notation. If not, _iwasm_ will return
|
||||
an error.
|
||||
should be announced first. Every IP address should be in CIDR notation.
|
||||
|
||||
```bash
|
||||
$ iwasm --addr-pool=1.2.3.4/15,2.3.4.6/16 socket_example.wasm
|
||||
|
@ -88,38 +87,3 @@ $ iwasm --addr-pool=1.2.3.4/15,2.3.4.6/16 socket_example.wasm
|
|||
```
|
||||
|
||||
Refer to [socket api sample](../samples/socket-api) for the compilation of the Wasm applications and [_iwasm_ for Intel SGX](../product-mini/platforms/linux-sgx) for the Wasm runtime.
|
||||
|
||||
## The background and compatibility notes
|
||||
|
||||
### WASIp1
|
||||
|
||||
The WASIp1 provides a subset of the socket API.
|
||||
Namely,
|
||||
|
||||
* send()
|
||||
* recv()
|
||||
* shutdown()
|
||||
* accept()
|
||||
|
||||
Functionalities like connect() and listen() are intentionally omitted
|
||||
there to maintain the capability-based security model, inherited from
|
||||
cloudabi. The common practice for applications is to make the host code
|
||||
pass already connected/listening sockets to wasm module.
|
||||
|
||||
### WAMR extensions
|
||||
|
||||
WAMR extends the WASIp1 with the rest of socket API functionalities
|
||||
for convenience.
|
||||
|
||||
* socket()
|
||||
* connect()
|
||||
* bind()
|
||||
* listen()
|
||||
* some of getsockopt/setsockopt options
|
||||
* name resolution (a subset of getaddrinfo)
|
||||
|
||||
### Compatibilities
|
||||
|
||||
Many of runtimes (eg. Wasmer and WasmEdge) provide similar extensions.
|
||||
Unfortunately, they are all incompatible. Thus, portable applications
|
||||
should not rely on these extensions.
|
||||
|
|
|
@ -45,7 +45,7 @@ libc_wasi_print_help(void)
|
|||
"path, for example:\n");
|
||||
printf(" --map-dir=<guest-path1::host-path1> "
|
||||
"--map-dir=<guest-path2::host-path2>\n");
|
||||
printf(" --addr-pool=<addr/mask> Grant wasi access to the given network "
|
||||
printf(" --addr-pool=<addrs> Grant wasi access to the given network "
|
||||
"addresses in\n");
|
||||
printf(" CIDR notation to the program, separated "
|
||||
"with ',',\n");
|
||||
|
|
|
@ -57,10 +57,6 @@ print_help(void)
|
|||
#else
|
||||
printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB when libc wasi is diabled\n");
|
||||
#endif
|
||||
#if WASM_ENABLE_SHARED_HEAP != 0
|
||||
printf(" --shared-heap-size=n Create shared heap of n bytes and attach to the wasm app.\n");
|
||||
printf(" The size n will be adjusted to a minumum number aligned to page size\n");
|
||||
#endif
|
||||
#if WASM_ENABLE_FAST_JIT != 0
|
||||
printf(" --jit-codecache-size=n Set fast jit maximum code cache size in bytes,\n");
|
||||
printf(" default is %u KB\n", FAST_JIT_DEFAULT_CODE_CACHE_SIZE / 1024);
|
||||
|
@ -582,11 +578,6 @@ main(int argc, char *argv[])
|
|||
#else
|
||||
uint32 heap_size = 16 * 1024;
|
||||
#endif
|
||||
#if WASM_ENABLE_SHARED_HEAP != 0
|
||||
SharedHeapInitArgs heap_init_args;
|
||||
uint32 shared_heap_size = 0;
|
||||
void *shared_heap = NULL;
|
||||
#endif
|
||||
#if WASM_ENABLE_FAST_JIT != 0
|
||||
uint32 jit_code_cache_size = FAST_JIT_DEFAULT_CODE_CACHE_SIZE;
|
||||
#endif
|
||||
|
@ -605,7 +596,6 @@ main(int argc, char *argv[])
|
|||
wasm_module_inst_t wasm_module_inst = NULL;
|
||||
RunningMode running_mode = 0;
|
||||
RuntimeInitArgs init_args;
|
||||
struct InstantiationArgs2 *inst_args;
|
||||
char error_buf[128] = { 0 };
|
||||
#if WASM_ENABLE_LOG != 0
|
||||
int log_verbose_level = 2;
|
||||
|
@ -694,13 +684,6 @@ main(int argc, char *argv[])
|
|||
return print_help();
|
||||
heap_size = atoi(argv[0] + 12);
|
||||
}
|
||||
#if WASM_ENABLE_SHARED_HEAP != 0
|
||||
else if (!strncmp(argv[0], "--shared-heap-size=", 19)) {
|
||||
if (argv[0][19] == '\0')
|
||||
return print_help();
|
||||
shared_heap_size = atoi(argv[0] + 19);
|
||||
}
|
||||
#endif
|
||||
#if WASM_ENABLE_FAST_JIT != 0
|
||||
else if (!strncmp(argv[0], "--jit-codecache-size=", 21)) {
|
||||
if (argv[0][21] == '\0')
|
||||
|
@ -966,20 +949,10 @@ main(int argc, char *argv[])
|
|||
libc_wasi_init(wasm_module, argc, argv, &wasi_parse_ctx);
|
||||
#endif
|
||||
|
||||
if (!wasm_runtime_instantiation_args_create(&inst_args)) {
|
||||
printf("failed to create instantiate args\n");
|
||||
goto fail3;
|
||||
}
|
||||
wasm_runtime_instantiation_args_set_default_stack_size(inst_args,
|
||||
stack_size);
|
||||
wasm_runtime_instantiation_args_set_host_managed_heap_size(inst_args,
|
||||
heap_size);
|
||||
|
||||
/* instantiate the module */
|
||||
wasm_module_inst = wasm_runtime_instantiate_ex2(
|
||||
wasm_module, inst_args, error_buf, sizeof(error_buf));
|
||||
wasm_runtime_instantiation_args_destroy(inst_args);
|
||||
if (!wasm_module_inst) {
|
||||
if (!(wasm_module_inst =
|
||||
wasm_runtime_instantiate(wasm_module, stack_size, heap_size,
|
||||
error_buf, sizeof(error_buf)))) {
|
||||
printf("%s\n", error_buf);
|
||||
goto fail3;
|
||||
}
|
||||
|
@ -1023,24 +996,6 @@ main(int argc, char *argv[])
|
|||
}
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_SHARED_HEAP != 0
|
||||
if (shared_heap_size > 0) {
|
||||
memset(&heap_init_args, 0, sizeof(heap_init_args));
|
||||
heap_init_args.size = shared_heap_size;
|
||||
shared_heap = wasm_runtime_create_shared_heap(&heap_init_args);
|
||||
if (!shared_heap) {
|
||||
printf("Create preallocated shared heap failed\n");
|
||||
goto fail6;
|
||||
}
|
||||
|
||||
/* attach module instance 2 to the shared heap */
|
||||
if (!wasm_runtime_attach_shared_heap(wasm_module_inst, shared_heap)) {
|
||||
printf("Attach shared heap failed.\n");
|
||||
goto fail6;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = 0;
|
||||
const char *exception = NULL;
|
||||
if (is_repl_mode) {
|
||||
|
@ -1084,9 +1039,6 @@ main(int argc, char *argv[])
|
|||
}
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_SHARED_HEAP != 0
|
||||
fail6:
|
||||
#endif
|
||||
#if WASM_ENABLE_THREAD_MGR != 0
|
||||
fail5:
|
||||
#endif
|
||||
|
|
|
@ -53,10 +53,6 @@ print_help()
|
|||
printf(" --gc-heap-size=n Set maximum gc heap size in bytes,\n");
|
||||
printf(" default is %u KB\n", GC_HEAP_SIZE_DEFAULT / 1024);
|
||||
#endif
|
||||
#if WASM_ENABLE_SHARED_HEAP != 0
|
||||
printf(" --shared-heap-size=n Create shared heap of n bytes and attach to the wasm app.\n");
|
||||
printf(" The size n will be adjusted to a minumum number aligned to page size\n");
|
||||
#endif
|
||||
#if WASM_ENABLE_JIT != 0
|
||||
printf(" --llvm-jit-size-level=n Set LLVM JIT size level, default is 3\n");
|
||||
printf(" --llvm-jit-opt-level=n Set LLVM JIT optimization level, default is 3\n");
|
||||
|
@ -368,13 +364,6 @@ main(int argc, char *argv[])
|
|||
gc_heap_size = atoi(argv[0] + 15);
|
||||
}
|
||||
#endif
|
||||
#if WASM_ENABLE_SHARED_HEAP != 0
|
||||
else if (!strncmp(argv[0], "--shared-heap-size=", 19)) {
|
||||
if (argv[0][19] == '\0')
|
||||
return print_help();
|
||||
shared_heap_size = atoi(argv[0] + 19);
|
||||
}
|
||||
#endif
|
||||
#if WASM_ENABLE_JIT != 0
|
||||
else if (!strncmp(argv[0], "--llvm-jit-size-level=", 22)) {
|
||||
if (argv[0][22] == '\0')
|
||||
|
@ -562,23 +551,6 @@ main(int argc, char *argv[])
|
|||
goto fail3;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_SHARED_HEAP != 0
|
||||
if (shared_heap_size > 0) {
|
||||
memset(&shared_heap_init_args, 0, sizeof(shared_heap_init_args));
|
||||
shared_heap_init_args.size = shared_heap_size;
|
||||
shared_heap = wasm_runtime_create_shared_heap(&shared_heap_init_args);
|
||||
|
||||
if (!shared_heap) {
|
||||
printf("Create shared heap failed.\n");
|
||||
goto fail5;
|
||||
}
|
||||
if (!wasm_runtime_attach_shared_heap(wasm_module_inst, shared_heap)) {
|
||||
printf("Attach shared heap failed.\n");
|
||||
goto fail5;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
if (ip_addr != NULL) {
|
||||
wasm_exec_env_t exec_env =
|
||||
|
@ -626,9 +598,6 @@ main(int argc, char *argv[])
|
|||
if (exception)
|
||||
printf("%s\n", exception);
|
||||
|
||||
#if WASM_ENABLE_SHARED_HEAP != 0
|
||||
fail5:
|
||||
#endif
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
fail4:
|
||||
#endif
|
||||
|
|
|
@ -3,23 +3,7 @@
|
|||
|
||||
# Refer to https://docs.zephyrproject.org/3.7.0/develop/getting_started/index.html
|
||||
# for more information on how to set up the Zephyr development environment.
|
||||
|
||||
# https://docs.zephyrproject.org/latest/develop/application/index.html#zephyr-workspace-application
|
||||
# zephyrproject/ --> CI ROOT
|
||||
# ├─── .west/
|
||||
# │ └─── config
|
||||
# ├─── bootloader/
|
||||
# ├─── zephyr/ --> Zephyr source code
|
||||
# ├─── zephyr-sdk/
|
||||
# ├─── modules/
|
||||
# │ |─── wasm-micro-runtime --> WAMR source code
|
||||
# ├─── tools/
|
||||
# ├─── vendor/
|
||||
# └─── application/ --> DUMMY. keep west_lite.yml here
|
||||
|
||||
# If you modify this file, you may need to sync the modifications to the
|
||||
# .github/actions/setup-zephyr/action.yml
|
||||
FROM ghcr.io/zephyrproject-rtos/ci-base:v0.26-branch
|
||||
FROM ubuntu:22.04
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ENV TZ=Asian/Shanghai
|
||||
|
@ -27,31 +11,44 @@ ARG ZEPHYR_SDK_VERSION=0.16.9
|
|||
# In west_lite.yml, the Zephyr version is set to v3.7.0
|
||||
#ARG ZEPHYR_VERSION=3.7.0
|
||||
|
||||
# Install the Zephyr Software Development Kit (SDK) minimal version
|
||||
WORKDIR /root/zephyrproject/zephyr-sdk
|
||||
# Install dependencies for Zephyr
|
||||
# hadolint ignore=DL3008
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends git cmake ninja-build gperf \
|
||||
ccache dfu-util device-tree-compiler wget \
|
||||
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
|
||||
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 \
|
||||
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install the Zephyr Software Development Kit (SDK)
|
||||
WORKDIR /opt
|
||||
# hadolint ignore=DL4006
|
||||
RUN wget --progress=dot:giga https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz \
|
||||
RUN wget --progress=dot:giga https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz \
|
||||
&& wget --progress=dot:giga -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/sha256.sum | shasum --check --ignore-missing \
|
||||
&& tar --strip-components=1 -xf zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz && rm zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz
|
||||
&& tar xf zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz && rm zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz
|
||||
|
||||
WORKDIR /opt/zephyr-sdk-${ZEPHYR_SDK_VERSION}
|
||||
# hadolint ignore=DL4006
|
||||
# Install arc tools, host tools and Register Zephyr SDK CMake package
|
||||
# If you want to use other toolchains, please change the -t option
|
||||
RUN ./setup.sh -t arc-zephyr-elf -h -c
|
||||
# Install host tools and Register Zephyr SDK CMake package
|
||||
RUN ./setup.sh -h -c
|
||||
|
||||
# Install west
|
||||
# hadolint ignore=DL3013,DL3059
|
||||
# Get Zephyr
|
||||
WORKDIR /root/zephyrproject/smoke-test
|
||||
|
||||
# hadolint ignore=DL3013
|
||||
RUN pip3 install --no-cache-dir west
|
||||
|
||||
# Setup a T2(Star topology) workspace
|
||||
WORKDIR /root/zephyrproject/application
|
||||
COPY ./west_lite.yml ./west_lite.yml
|
||||
COPY ./west_lite.yml ./west.yml
|
||||
|
||||
# init the west workspace with a minimal manifest
|
||||
RUN west init -l --mf west_lite.yml .
|
||||
RUN west init -l
|
||||
|
||||
WORKDIR /root/zephyrproject
|
||||
RUN west update --stats
|
||||
|
||||
WORKDIR /root/zephyrproject/modules/zephyr
|
||||
RUN west zephyr-export && pip install --no-cache-dir -r ./scripts/requirements.txt
|
||||
|
||||
ENV ZEPHYR_BASE="/root/zephyrproject/modules/zephyr"
|
||||
|
||||
# Git clone wamr
|
||||
WORKDIR /root/zephyrproject/modules/
|
||||
RUN git clone https://github.com/bytecodealliance/wasm-micro-runtime.git wasm-micro-runtime
|
||||
|
|
|
@ -8,8 +8,8 @@ manifest:
|
|||
url: https://github.com/zephyrproject-rtos/zephyr
|
||||
revision: v3.7.0
|
||||
clone-depth: 1
|
||||
path: zephyr
|
||||
path: modules/zephyr
|
||||
west-commands: scripts/west-commands.yml
|
||||
|
||||
self:
|
||||
path: application
|
||||
path: smoke-test
|
||||
|
|
|
@ -171,7 +171,6 @@ set(WAMR_BUILD_JIT 0)
|
|||
set(WAMR_BUILD_LIBC_BUILTIN 1)
|
||||
set(WAMR_BUILD_LIBC_WASI 1)
|
||||
set(WAMR_BUILD_LIB_PTHREAD 1)
|
||||
set(WAMR_BUILD_REF_TYPES 1)
|
||||
|
||||
# compiling and linking flags
|
||||
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#define WASM_CURRENT_VERSION 1
|
||||
|
||||
#define AOT_MAGIC_NUMBER 0x746f6100
|
||||
#define AOT_CURRENT_VERSION 5
|
||||
#define AOT_CURRENT_VERSION 4
|
||||
|
||||
/* Legal values for bin_type */
|
||||
#define BIN_TYPE_ELF32L 0 /* 32-bit little endian */
|
||||
|
|
|
@ -11,7 +11,6 @@ import subprocess
|
|||
import glob
|
||||
import re
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
from typing import Dict, Optional, List
|
||||
|
||||
|
@ -276,11 +275,6 @@ def process_and_run_test_cases(
|
|||
else:
|
||||
print(f" Issues not found in folder: {format_issue_ids_should_test}")
|
||||
|
||||
if failed > 0:
|
||||
# Exit with error code if there are failed test for CI
|
||||
print("Some tests failed, see log file for details.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Run BA issue tests.")
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
"argument": "",
|
||||
"expected return": {
|
||||
"ret code": 255,
|
||||
"stdout content": "WASM module load failed: unexpected end opcodes from unbalanced control flow structures",
|
||||
"stdout content": "WASM module load failed: END opcode expected",
|
||||
"description": "no sanitizer 'Heap Buffer Overflow'"
|
||||
}
|
||||
},
|
||||
|
@ -979,7 +979,7 @@
|
|||
"argument": "",
|
||||
"expected return": {
|
||||
"ret code": 255,
|
||||
"stdout content": "WASM module load failed: section size mismatch: function body END opcode expected",
|
||||
"stdout content": "WASM module load failed: unexpected end of section or function",
|
||||
"description": "no 'Heap out of bound read of size 1 in wasm_loader_prepare_bytecode function'"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -3,17 +3,5 @@
|
|||
# Copyright (C) 2020 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
|
||||
cleanup() {
|
||||
local exit_code=$?
|
||||
rm -rf "$TEMP_DIR"
|
||||
exit $exit_code
|
||||
}
|
||||
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
/usr/bin/env python3 -m venv --clear "$TEMP_DIR"
|
||||
source "$TEMP_DIR/bin/activate"
|
||||
/usr/bin/env python3 -m pip install -r ../build-scripts/requirements.txt
|
||||
/usr/bin/env python3 -m pip install --user -r ../build-scripts/requirements.txt
|
||||
/usr/bin/env python3 ../build-scripts/build_llvm.py "$@"
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
# Copyright (C) 2020 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
$SCRIPT_DIR/build_llvm.sh --platform arc "$@"
|
||||
/usr/bin/env python3 -m pip install --user -r ../build-scripts/requirements.txt
|
||||
/usr/bin/env python3 ../build-scripts/build_llvm.py --platform arc "$@"
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
# Copyright (C) 2020 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
$SCRIPT_DIR/build_llvm.sh --platform xtensa "$@"
|
||||
/usr/bin/env python3 -m pip install --user -r ../build-scripts/requirements.txt
|
||||
/usr/bin/env python3 ../build-scripts/build_llvm.py --platform xtensa "$@"
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
# wasm-wasi-extensions
|
||||
|
||||
wasm-wasi-extensions is a set of small static libraries
|
||||
which aims to help you build a wasm module using
|
||||
WAMR's extensions to WASIp1.
|
||||
It's expected to be used in combination with WASI-SDK.
|
||||
|
||||
Currently it contains bindings for the following APIs:
|
||||
|
||||
* wasi-nn
|
||||
|
||||
* lib-socket
|
||||
|
||||
## Usage
|
||||
|
||||
### Preparation
|
||||
|
||||
Place it somewhere in your `CMAKE_PREFIX_PATH`.
|
||||
|
||||
You may want to automate the process with `FetchContent`.
|
||||
```
|
||||
set(URL https://github.com/bytecodealliance/wasm-micro-runtime/releases/download/WAMR-2.4.0/wamr-wasi-extensions-2.4.0.zip)
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
wamr-wasi-extensions
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
|
||||
URL ${URL}
|
||||
)
|
||||
FetchContent_MakeAvailable(wamr-wasi-extensions)
|
||||
list(APPEND CMAKE_PREFIX_PATH ${wamr-wasi-extensions_SOURCE_DIR})
|
||||
```
|
||||
|
||||
Now you can use cmake find_package and link it to your application.
|
||||
You can find samples in the [samples](samples) directory.
|
||||
|
||||
### wasi-nn
|
||||
|
||||
```
|
||||
find_package(wamr-wasi-nn REQUIRED)
|
||||
target_link_libraries(you-app wamr-wasi-nn)
|
||||
```
|
||||
|
||||
### lib-socket
|
||||
|
||||
```
|
||||
find_package(wamr-wasi-socket REQUIRED)
|
||||
target_link_libraries(your-app wamr-wasi-socket)
|
||||
```
|
|
@ -31,18 +31,18 @@ load_graph(char *options)
|
|||
const char *id = "default";
|
||||
wasi_ephemeral_nn_graph_builder *builders = NULL;
|
||||
size_t nbuilders = 0;
|
||||
const char *name = NULL;
|
||||
enum {
|
||||
opt_id,
|
||||
opt_file,
|
||||
opt_name,
|
||||
opt_encoding,
|
||||
opt_target,
|
||||
};
|
||||
static char *const keylistp[] = {
|
||||
[opt_id] = "id", [opt_file] = "file",
|
||||
[opt_name] = "name", [opt_encoding] = "encoding",
|
||||
[opt_target] = "target", NULL,
|
||||
[opt_id] = "id",
|
||||
[opt_file] = "file",
|
||||
[opt_encoding] = "encoding",
|
||||
[opt_target] = "target",
|
||||
NULL,
|
||||
};
|
||||
while (*options) {
|
||||
extern char *suboptarg;
|
||||
|
@ -74,13 +74,6 @@ load_graph(char *options)
|
|||
exit(1);
|
||||
}
|
||||
break;
|
||||
case opt_name:
|
||||
if (value == NULL) {
|
||||
fprintf(stderr, "no value for %s\n", saved);
|
||||
exit(2);
|
||||
}
|
||||
name = value;
|
||||
break;
|
||||
case opt_encoding:
|
||||
if (value == NULL) {
|
||||
fprintf(stderr, "no value for %s\n", saved);
|
||||
|
@ -101,25 +94,13 @@ load_graph(char *options)
|
|||
}
|
||||
}
|
||||
|
||||
if (name != NULL && nbuilders != 0) {
|
||||
fprintf(stderr, "name and file are exclusive\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
wasi_ephemeral_nn_error nnret;
|
||||
wasi_ephemeral_nn_graph g;
|
||||
if (name != NULL) {
|
||||
/* we ignore encoding and target */
|
||||
nnret = wasi_ephemeral_nn_load_by_name(name, strlen(name), &g);
|
||||
}
|
||||
else {
|
||||
nnret =
|
||||
wasi_ephemeral_nn_load(builders, nbuilders, encoding, target, &g);
|
||||
size_t i;
|
||||
for (i = 0; i < nbuilders; i++) {
|
||||
wasi_ephemeral_nn_graph_builder *b = &builders[i];
|
||||
unmap_file(b->buf, b->size);
|
||||
}
|
||||
nnret = wasi_ephemeral_nn_load(builders, nbuilders, encoding, target, &g);
|
||||
size_t i;
|
||||
for (i = 0; i < nbuilders; i++) {
|
||||
wasi_ephemeral_nn_graph_builder *b = &builders[i];
|
||||
unmap_file(b->buf, b->size);
|
||||
}
|
||||
if (nnret != wasi_ephemeral_nn_error_success) {
|
||||
fprintf(stderr, "load failed with %d\n", (int)nnret);
|
||||
|
|
Loading…
Reference in New Issue
Block a user