Skip to content

Commit

Permalink
various: remove ATOMIC_VAR_INIT
Browse files Browse the repository at this point in the history
the fallback needed it due to the struct wrapper. but the fallback is
now removed so it's no longer needed.

as for standard atomics, it was never really needed either, was useless
and then removed in C17.

ref: https://gustedt.wordpress.com/2018/08/06/c17-obsoletes-atomic_var_init/
ref: https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT
  • Loading branch information
N-R-K committed Oct 19, 2023
1 parent 8d8d3a4 commit 8bab3bd
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion common/msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ void mp_msg_init(struct mpv_global *global)
struct mp_log_root *root = talloc_zero(NULL, struct mp_log_root);
*root = (struct mp_log_root){
.global = global,
.reload_counter = ATOMIC_VAR_INIT(1),
.reload_counter = 1,
};

pthread_mutex_init(&root->lock, NULL);
Expand Down
2 changes: 1 addition & 1 deletion filters/f_async_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct mp_async_queue *mp_async_queue_create(void)
struct mp_async_queue *r = talloc_zero(NULL, struct mp_async_queue);
r->q = talloc_zero(NULL, struct async_queue);
*r->q = (struct async_queue){
.refcount = ATOMIC_VAR_INIT(1),
.refcount = 1,
};
pthread_mutex_init(&r->q->lock, NULL);
talloc_set_destructor(r, on_free_queue);
Expand Down
2 changes: 1 addition & 1 deletion misc/thread_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct mp_cancel *mp_cancel_new(void *talloc_ctx)
struct mp_cancel *c = talloc_ptrtype(talloc_ctx, c);
talloc_set_destructor(c, cancel_destroy);
*c = (struct mp_cancel){
.triggered = ATOMIC_VAR_INIT(false),
.triggered = false,
.wakeup_pipe = {-1, -1},
};
pthread_mutex_init(&c->lock, NULL);
Expand Down
2 changes: 1 addition & 1 deletion osdep/windows_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ char *mp_HRESULT_to_str_buf(char *buf, size_t buf_size, HRESULT hr)
bool mp_w32_create_anon_pipe(HANDLE *server, HANDLE *client,
struct w32_create_anon_pipe_opts *opts)
{
static atomic_ulong counter = ATOMIC_VAR_INIT(0);
static atomic_ulong counter = 0;

// Generate pipe name
unsigned long id = atomic_fetch_add(&counter, 1);
Expand Down
2 changes: 1 addition & 1 deletion sub/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct osd_state *osd_create(struct mpv_global *global)
.opts_cache = m_config_cache_alloc(osd, global, &mp_osd_render_sub_opts),
.global = global,
.log = mp_log_new(osd, global->log, "osd"),
.force_video_pts = ATOMIC_VAR_INIT(MP_NOPTS_VALUE),
.force_video_pts = MP_NOPTS_VALUE,
.stats = stats_ctx_create(osd, global, "osd"),
};
pthread_mutex_init(&osd->lock, NULL);
Expand Down
2 changes: 1 addition & 1 deletion video/out/dr_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct dr_helper *dr_helper_create(struct mp_dispatch_queue *dispatch,
talloc_set_destructor(dr, dr_helper_destroy);
*dr = (struct dr_helper){
.dispatch = dispatch,
.dr_in_flight = ATOMIC_VAR_INIT(0),
.dr_in_flight = 0,
.get_image = get_image,
.get_image_ctx = get_image_ctx,
};
Expand Down

0 comments on commit 8bab3bd

Please sign in to comment.