refactor(core): C++23 Wave 5 — cpu, ref, thread_locale (ADR-0735)#58
Open
lusoris wants to merge 2 commits into
Open
refactor(core): C++23 Wave 5 — cpu, ref, thread_locale (ADR-0735)#58lusoris wants to merge 2 commits into
lusoris wants to merge 2 commits into
Conversation
Convert three small core/src/*.c files to C++23, continuing the ADR-0708 migration playbook (isolated static_library per TU, cpp_std=c++23 scoped): - cpu.cpp: std::atomic<unsigned> for CPU-flag state, eliminating a potential data-race on multi-threaded init; memory_order_relaxed on the hot vmaf_get_cpu_flags() read path preserves zero overhead. - ref.cpp: std::make_unique<VmafRef>() replaces malloc+memset+atomic_init; early-return paths are leak-safe; vmaf_ref_close uses delete (matching operator new). extern "C" guards added to ref.h. - thread_locale.cpp: VmafThreadLocaleState destructor encapsulates platform teardown (POSIX uselocale/freelocale, Win32 _configthreadlocale); vmaf_thread_locale_pop reduced to a unique_ptr adopt-and-destroy one-liner; std::array<char,256> on Windows. Public C ABI preserved. Build: 726/726. Tests: 49/49 fast suite pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
48277d0 to
4cbad1d
Compare
10 tasks
Contributor
Author
|
CRITICAL finding from adversarial review: |
…in vmaf_ref_close (adversarial review PR #78) make_unique uses operator new; vmaf_ref_close (C ABI) must use free() to match the legacy allocator contract and keep ref.c (test harness) and ref.cpp consistent. Switch to malloc+placement-new and document in ref.h that vmaf_ref_close is the sole valid deallocator. Fixes the CRITICAL allocator-mismatch finding in adversarial review PR #78. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cpu.c → cpu.cpp:std::atomic<unsigned>for CPU-flag globals — eliminates potential init-time data-race;memory_order_relaxedon the hotvmaf_get_cpu_flags()read path.ref.c → ref.cpp:std::make_unique<VmafRef>()replacesmalloc+memset+atomic_init; leak-safe error paths;vmaf_ref_closeusesdelete;extern "C"guards added toref.h.thread_locale.c → thread_locale.cpp:VmafThreadLocaleStatedestructor encapsulates platform teardown (POSIX / Win32);vmaf_thread_locale_popis aunique_ptrone-liner;std::array<char,256>on Windows.Each file compiled as an isolated
static_librarywithoverride_options: ['cpp_std=c++23'](ADR-0708 pattern). Public C ABI preserved unchanged.Test plan
Checklist (ADR-0108 six deliverables)
no digest needed: bulk Wave 5 continues ADR-0708 playbookdocs/adr/0735-cpp23-wave5-bundle.md§ Alternatives consideredcore/AGENTS.md— C++23 migration surface table updatedchangelog.d/changed/cpp23-wave5.mddocs/rebase-notes.md— ADR-0735 entryPer-surface docs
no user-discoverable surface change — internal refactordocs/state.md
no bug opened/closed/ruled-out — refactor onlyffmpeg-patches
no public C-API change — internal TUs only🤖 Generated with Claude Code