聯絡我們

LibReviewQA

Platform acceptance test library: wrapping add and saturating multiply.

函式庫開發者 SignalPlus

取得將在 SignalPlus OS 中開啟,登入後即可安裝。
評分
—
尚無評分
價格
免費
版本
1
2026年11月6日
開發者
SignalPlus

關於這個函式庫

LibReviewQA

Small integer helpers (wrapping add, saturating multiply) published by the platform team to exercise Marketplace Library review end to end. Pure compute — the consuming app passes integers in and gets integers back; the library performs no I/O and keeps no state.

Interface

All functions use the C ABI (see include/01a1b01b-9b1a-7271-9366-b36f2024e789.h). Scalars only.

sp2_01a1b01b_9b1a_7271_9366_b36f2024e789_init() -> i32

One-time initialisation. The consuming app MUST call this exactly once from its init() before any other function. Returns 0 on success.

| Return | Meaning | | ------ | ------- | | 0 | success (the only value returned) |

sp2_01a1b01b_9b1a_7271_9366_b36f2024e789_add(a: i32, b: i32) -> i32

Returns a + b with two's-complement wrapping on overflow (for example add(i32::MAX, 1) == i32::MIN). Never fails.

sp2_01a1b01b_9b1a_7271_9366_b36f2024e789_mul_saturating(a: i32, b: i32) -> i32

Returns a * b, clamped to i32::MIN / i32::MAX when the exact product does not fit (for example mul_saturating(65536, 65536) == i32::MAX). Never fails.

Usage in a consuming app

backend/Cargo.toml (rename the dependency — the raw crate name is not a valid Rust identifier):

[dependencies]
mylib = { package = "sp2019e3a82f6bc77ee9a56cfbd377c5f5f-01a1b01b-9b1a-7271-9366-b36f2024e789-sys", version = "0.1.2", registry = "sp2-cargo" }

backend/src/lib.rs:

fn try_init() -> Result<(), String> {
    let rc = unsafe { mylib::sp2_01a1b01b_9b1a_7271_9366_b36f2024e789_init() };
    if rc != 0 {
        return Err(format!("lib init failed: {rc}"));
    }
    let sum = unsafe { mylib::sp2_01a1b01b_9b1a_7271_9366_b36f2024e789_add(1, 2) };
    let product = unsafe { mylib::sp2_01a1b01b_9b1a_7271_9366_b36f2024e789_mul_saturating(sum, 7) };
    let _ = product;
    Ok(())
}

Deployed apps pin exact versions via Cargo.lock.

Versioning & compatibility

  • Entitlement is per-lib: one purchase unlocks all released versions; a version priced above what was already paid costs the difference, and zero-difference upgrades apply automatically.
  • Breaking the C ABI (changing/removing an exported symbol) requires a new major version.
  • 0.1.x: initial interface (init, add, mul_saturating).

Pricing & entitlement notes

Free test library for platform acceptance; no expiry.

新功能

版本 1 · 2026年11月6日

0.1.2: initial interface (init, add, mul_saturating).

資訊

開發者
SignalPlus
類型
函式庫
價格
免費
Remix
不開放 Remix
上架時間
2026年11月6日

同一開發者的更多作品

App 市場中的 App 由獨立開發者製作,上架前經 SignalPlus 審核;介紹文字由開發者提供。本站內容不構成投資建議,也不承諾收益。