|WARNING| [v2] eal: fix C++ builds when stdatomics is set
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Fri Sep 25 15:27:48 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/170037
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-09-25
# DPDK Patch Review
## Patch: [PATCH v2] eal: fix C++ builds when stdatomics is set
### Summary
This patch fixes C++ compilation failures when `enable_stdatomic=true` is set by providing separate C++ compatible atomic definitions. The patch splits the standard atomics path into C and C++ blocks.
---
## ERRORS
None found.
---
## WARNINGS
### 1. CI script test coverage change
**File:** `.ci/linux-build.sh`
**Lines:** 111-120
The logic change removes the condition preventing `check_includes=true` when `STDATOMIC=true`. This means C++ header checks will now run with stdatomics enabled.
**Why it matters:** This changes test coverage but appears intentional to validate the fix. However, the commit message should explicitly mention that CI now tests C++ includes with stdatomics enabled.
**Suggested addition to commit message:**
```
The CI is also updated to enable C++ header checking when stdatomics
is enabled, validating that the fix works correctly.
```
### 2. Code duplication between C and C++ paths
**File:** `lib/eal/include/rte_stdatomic.h`
**Lines:** 119-189
The C++ block duplicates ~60 lines of macro definitions from the existing builtin atomics implementation. This duplication creates maintenance burden if either block needs updates.
**Why it matters:** Future changes to atomic operations would need to be applied in two places, risking divergence.
**Suggested approach:** Add a comment noting the duplication and why it exists:
```c
/* NOTE: This block duplicates the builtin atomics implementation below.
* C++ cannot use C11 _Atomic types in DPDK's public header layout,
* so it must use builtins even when enable_stdatomic=true for C code.
* Keep these definitions synchronized with the builtin block.
*/
```
---
## INFO
### 1. Well-structured fix
The three-way split (builtins, C11 atomics for C, builtins for C++) is a clean solution to the C/C++ atomics incompatibility. The approach maintains backward compatibility for C builds while enabling C++ builds.
### 2. Good use of preprocessor organization
The nesting structure (`#ifdef RTE_ENABLE_STDATOMIC` - `#ifndef __cplusplus` - `#else` - `#endif`) is clear and logically organized.
---
## CORRECTNESS VERIFICATION
**No resource leaks:** No dynamic allocations or resource management.
**No use-after-free:** Only preprocessor macros and type definitions.
**No race conditions:** Defines atomic operation wrappers; does not introduce shared mutable state.
**Thread safety:** The macros correctly map to GCC builtin atomic operations for C++, matching the existing builtin implementation semantics.
**Memory ordering:** All memory order macros correctly map to `__ATOMIC_*` constants for both C and C++ paths.
---
## STYLE COMPLIANCE
**Indentation:** Properly uses tabs.
**Comments:** C-style comments used appropriately.
**Macro naming:** Follows existing `rte_*` and `__rte_*` conventions.
**Preprocessor structure:** Clear conditional compilation blocks.
**No forbidden tokens:** No usage of deprecated atomics, volatile for synchronization, or other forbidden patterns.
---
## API AND DOCUMENTATION
**API consistency:** The C++ path exposes the same `rte_atomic_*` API as the C path, maintaining compatibility.
**No ABI changes:** Only preprocessor definitions; no symbol changes.
**Release notes:** The commit message references Bugzilla ID 1985 and includes `Fixes:` tag with `Cc: stable at dpdk.org`. No release notes needed for a build fix.
**Documentation gap:** The `rte_stdatomic.h` file lacks a top-level comment explaining the three-way structure. Consider adding:
```c
/**
* @file
*
* DPDK atomic operations wrapper.
*
* Provides a unified API for atomic operations that works across C and C++:
* - When enable_stdatomic=true: C code uses C11 <stdatomic.h>
* - C++ code always uses GCC builtin atomics (C11 _Atomic incompatible)
* - When enable_stdatomic=false: all code uses GCC builtin atomics
*/
```
---
## OVERALL ASSESSMENT
**Recommendation:** Accept with minor documentation improvements.
The patch correctly solves the C++ compilation failure by recognizing that C11 `_Atomic` types and C++ `std::atomic` are incompatible in DPDK's header layout. The solution to use GCC builtins for C++ is sound and maintains API compatibility.
The code duplication is unavoidable given the structural constraints, but should be documented to help future maintainers. The CI change is appropriate but should be mentioned in the commit message.
No correctness bugs identified. The implementation is safe and follows DPDK conventions.
More information about the test-report
mailing list