librice: Fix build on targets without 64-bit atomics

rice-proto counts agents in a core AtomicU64, which is not available on
targets without 64-bit atomics, so it fails to build for riscv32:

  error[E0432]: unresolved import `core::sync::atomic::AtomicU64`

Add a patch that uses AtomicUsize for it, like the other id counters
in rice-proto, keeping the u64 agent id.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
Khem Raj committed 2026-10-22 09:58:55 -07:00
1 parent 685776c556
commit e89deee841
2 files changed
+53 -1

No files matched your search

@@ -0,0 +1,50 @@
From: Khem Raj <khem.raj@oss.qualcomm.com>
Date: Thu, 22 Oct 2026 14:00:00 -0700
Subject: [PATCH] rice-proto: Use AtomicUsize for the agent counter
core only provides AtomicU64 on targets with 64-bit atomics, so
rice-proto fails to build for e.g. riscv32:
error[E0432]: unresolved import `core::sync::atomic::AtomicU64`
--> rice-proto/src/agent.rs:19:5
AGENT_COUNT only hands out agent ids, like the STUN agent, connection
check and check list counters, which are already AtomicUsize. Use
AtomicUsize for it as well and widen the value to the u64 id, so
Agent::id() is unchanged.
Upstream-Status: Submitted [https://github.com/ystreet/librice/pull/202]
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
rice-proto/src/agent.rs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/rice-proto/src/agent.rs
+++ b/rice-proto/src/agent.rs
@@ -16,7 +16,7 @@
use core::error::Error;
use core::fmt::Display;
use core::net::SocketAddr;
-use core::sync::atomic::AtomicU64;
+use core::sync::atomic::AtomicUsize;
use core::time::Duration;
use stun_proto::Instant;
@@ -189,7 +189,7 @@
turn_client_proto::types::debug_init();
rice_stun_types::debug_init();
- let id = AGENT_COUNT.fetch_add(1, core::sync::atomic::Ordering::SeqCst);
+ let id = AGENT_COUNT.fetch_add(1, core::sync::atomic::Ordering::SeqCst) as u64;
let tie_breaker = rand_u64();
let controlling = self.controlling;
let mut checklistset = ConnCheckListSet::builder(tie_breaker, controlling)
@@ -210,7 +210,7 @@
}
}
-static AGENT_COUNT: AtomicU64 = AtomicU64::new(0);
+static AGENT_COUNT: AtomicUsize = AtomicUsize::new(0);
impl Default for Agent {
fn default() -> Self {
@@ -3,7 +3,9 @@ HOMEPAGE = "https://github.com/ystreet/librice"
LICENSE = "MIT" LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE-MIT;md5=b377b220f43d747efdec40d69fcaa69d" LIC_FILES_CHKSUM = "file://LICENSE-MIT;md5=b377b220f43d747efdec40d69fcaa69d"
SRC_URI += " git://github.com/ystreet/librice.git;protocol=https;branch=main;tag=v${PV}" SRC_URI += " git://github.com/ystreet/librice.git;protocol=https;branch=main;tag=v${PV} \
file://0001-rice-proto-Use-AtomicUsize-for-the-agent-counter.patch \
"
SRCREV = "afd70fdd7ca96a39824c55e6b373bac97311f2ba" SRCREV = "afd70fdd7ca96a39824c55e6b373bac97311f2ba"
DEPENDS += "openssl clang-native" DEPENDS += "openssl clang-native"