msvc: round out stdatomic shim and select native C11 atomics

Three small MSVC-only build fixes that travel together:

* compat/msvc/stdatomic.h: define atomic_uint_fast64_t. It is used by
  rist-private.h for the sender/receiver data_fd rx/tx packet and byte
  counters. Without this the MSVC fallback path fails to compile as
  soon as any caller reaches those members.

* compat/msvc/stdatomic.h: fix a one-underscore typo on the
  atomic_uint_fast16_t typedef (_declspec -> __declspec). MSVC accepts
  the single-underscore spelling as a deprecated alias and newer
  releases warn on it.

* meson.build: when the compiler is MSVC, enable /std:c11 (or /std:c17
  as a fallback) so MSVC's own <stdatomic.h> becomes visible; propagate
  stdatomic_dependency through the exported librist_dep so consumers
  linking against librist get the same atomics plumbing.

Together with the preceding poll_win fix this is what Manuel's AI-
generated patch was trying to achieve; this version keeps the real
fixes, drops the churn, and makes the commit shape readable.

Reported-by: Manuel <manueldev@code.videolan.org>
Refs: https://code.videolan.org/rist/librist/-/issues/182
This commit is contained in:
Sergio Ammirata
2026-04-22 10:06:27 -04:00
parent 7890a35f9d
commit 49ec8c6698
2 changed files with 12 additions and 2 deletions
+2 -1
View File
@@ -29,7 +29,8 @@ typedef volatile ULONG __declspec(align(32)) atomic_bool;
typedef volatile ULONG __declspec(align(32)) atomic_int;
typedef volatile ULONG __declspec(align(32)) atomic_uint;
typedef volatile ULONG __declspec(align(32)) atomic_ulong;
typedef volatile USHORT _declspec(align(16)) atomic_uint_fast16_t;
typedef volatile USHORT __declspec(align(16)) atomic_uint_fast16_t;
typedef volatile ULONG64 __declspec(align(32)) atomic_uint_fast64_t;
typedef enum {
memory_order_relaxed,
+10 -1
View File
@@ -114,6 +114,15 @@ windows_version_test = '''
else
have_pthreads = false
endif
if cc.get_id() == 'msvc'
# librist uses C11 features (stdatomic.h, mixed declarations).
# MSVC only exposes them under /std:c11 or /std:c17.
if cc.has_argument('/std:c11')
add_project_arguments(['/std:c11'], language: 'c')
elif cc.has_argument('/std:c17')
add_project_arguments(['/std:c17'], language: 'c')
endif
endif
add_project_arguments(['-DWIN32_LEAN_AND_MEAN'], language: 'c')
add_project_arguments(['-D__USE_MINGW_ANSI_STDIO=1'], language: 'c')
add_project_arguments(['-D_CRT_NONSTDC_NO_DEPRECATE'], language: 'c')
@@ -389,7 +398,7 @@ if get_option('static_analyze')
run_target('analyze', command: ['bash', join_paths(librist_src_root, 'common/scripts/analyze.sh')])
endif
librist_dep = declare_dependency(include_directories: inc, link_with : librist)
librist_dep = declare_dependency(include_directories: inc, link_with : librist, dependencies : stdatomic_dependency)
if get_option('built_tools')
message('Building tools')