remove deprecated ATOMIC_VAR_INIT() usage

It's deprecated in C17 [1]. Atomic initializers don't need this macro.

Even with std=gnu11, clang 14+ would issue a warning it's deprecated.

[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2244.htm#dr_485
This commit is contained in:
Steve Lhomme 2024-01-29 12:49:49 +01:00
parent b57f2c7eb8
commit 9f113f8e61
8 changed files with 11 additions and 11 deletions

View File

@ -41,7 +41,7 @@ using std::memory_order_acq_rel;
#include <time.h> /* vlc_atomic_timedwait_daytime */
#define VLC_STATIC_RC { \
.refs = ATOMIC_VAR_INIT(0) \
.refs = 0 \
}
typedef struct vlc_atomic_rc_t {

View File

@ -163,9 +163,9 @@ typedef struct
* In C++, consider using a global ::vlc::threads::mutex instance instead.
*/
#define VLC_STATIC_MUTEX { \
.value = ATOMIC_VAR_INIT(0), \
.recursion = ATOMIC_VAR_INIT(0), \
.owner = ATOMIC_VAR_INIT(0), \
.value = 0, \
.recursion = 0, \
.owner = 0, \
}
/**
@ -527,7 +527,7 @@ typedef struct
/**
* Static initializer for one-time initialization.
*/
#define VLC_STATIC_ONCE { ATOMIC_VAR_INIT(0) }
#define VLC_STATIC_ONCE { 0 }
/**
* Begins a one-time initialization.

View File

@ -67,7 +67,7 @@ vlc_module_begin()
set_callback( OpenEncoder )
vlc_module_end()
static atomic_bool busy = ATOMIC_VAR_INIT(false);
static atomic_bool busy = false;
static int OpenEncoder( vlc_object_t *p_this )
{

View File

@ -151,7 +151,7 @@ static void WindowUnsetFullscreen(vlc_window_t *wnd)
WindowSetFullscreen(wnd, &windowed);
}
static atomic_bool b_intf_starting = ATOMIC_VAR_INIT(false);
static atomic_bool b_intf_starting = false;
static const struct vlc_window_operations ops = {
WindowEnable,

View File

@ -300,7 +300,7 @@ check_service_running(void)
/* Cache the return of this function that may take up to 200ms. This atomic
* doesn't prevent a cache miss (unlikely). This function can be called
* safely from any threads. */
static atomic_int cache_running = ATOMIC_VAR_INIT(0);
static atomic_int cache_running = 0;
int running = atomic_load_explicit(&cache_running, memory_order_relaxed);
if (running != 0)
return running == 1 ? VLC_SUCCESS : VLC_EGENERIC;

View File

@ -41,7 +41,7 @@
#include "misc/rcu.h"
static vlc_mutex_t config_lock = VLC_STATIC_MUTEX;
static atomic_bool config_dirty = ATOMIC_VAR_INIT(false);
static atomic_bool config_dirty = false;
void config_Lock(void)
{

View File

@ -146,7 +146,7 @@ out:
unsigned vlc_CPU(void)
{
static atomic_uint cpu_flags = ATOMIC_VAR_INIT(-1U);
static atomic_uint cpu_flags = -1U;
unsigned flags = atomic_load_explicit(&cpu_flags, memory_order_relaxed);
if (unlikely(flags == -1U)) {

View File

@ -51,7 +51,7 @@ typedef struct {
atomic_ulong owner;
} vlc_queuedmutex_t;
#define VLC_STATIC_QUEUEDMUTEX { ATOMIC_VAR_INIT(0), ATOMIC_VAR_INIT(0), ATOMIC_VAR_INIT(0) }
#define VLC_STATIC_QUEUEDMUTEX { 0, 0, 0 }
void vlc_queuedmutex_init(vlc_queuedmutex_t *m);