MT#55283 use non-glib atomic macros in more places

Change-Id: Ia1e92f1d665a1773d25160a1ed4e4e93ae7b8ec2
pull/1126/merge
Richard Fuchs 2 months ago
parent 1779beeea0
commit 859ac06626

@ -4940,7 +4940,7 @@ static int handler_func_transcode(struct codec_handler *h, struct media_packet *
if (h->stats_entry) {
unsigned int idx = rtpe_now.tv_sec & 1;
int last_tv_sec = g_atomic_int_get(&h->stats_entry->last_tv_sec[idx]);
int last_tv_sec = atomic_get_na(&h->stats_entry->last_tv_sec[idx]);
if (last_tv_sec != (int) rtpe_now.tv_sec) {
if (g_atomic_int_compare_and_exchange(&h->stats_entry->last_tv_sec[idx],
last_tv_sec, rtpe_now.tv_sec))

@ -69,8 +69,7 @@ static socket_slist *ng_client_get_socket(struct endpoint_sockets *es) {
socket_slist *link = __atomic_load_n(&es->sockets, __ATOMIC_SEQ_CST);
bool success = false;
while (link && !success)
success = __atomic_compare_exchange_n(&es->sockets, &link, link->next,
false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
success = atomic_compare_exchange(&es->sockets, &link, link->next);
if (link) {
link->next = NULL;
@ -100,8 +99,7 @@ static void ng_client_put_socket(struct endpoint_sockets *es, socket_slist *link
link->next = __atomic_load_n(&es->sockets, __ATOMIC_SEQ_CST);
bool success;
do
success = __atomic_compare_exchange_n(&es->sockets, &link->next, link,
false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
success = atomic_compare_exchange(&es->sockets, &link->next, link);
while (!success);
}

@ -188,13 +188,13 @@ static void mos_calc_legacy(struct ssrc_stats_block *ssb) {
static void *find_ssrc(uint32_t ssrc, struct ssrc_hash *ht) {
rwlock_lock_r(&ht->lock);
struct ssrc_entry *ret = g_atomic_pointer_get(&ht->cache);
struct ssrc_entry *ret = atomic_get_na(&ht->cache);
if (!ret || ret->ssrc != ssrc) {
ret = g_hash_table_lookup(ht->ht, &ssrc);
if (ret) {
obj_hold(ret);
// cache shares the reference from ht
g_atomic_pointer_set(&ht->cache, ret);
atomic_set_na(&ht->cache, ret);
ret->last_used = rtpe_now.tv_sec;
}
}
@ -231,11 +231,11 @@ restart:
}
// use precreated entry if possible
ent = atomic_get_na(&ht->precreat);
while (1) {
ent = g_atomic_pointer_get(&ht->precreat);
if (!ent)
break; // create one ourselves
if (g_atomic_pointer_compare_and_exchange(&ht->precreat, ent, NULL))
if (atomic_compare_exchange(&ht->precreat, &ent, NULL))
break;
// something got in the way - retry
}
@ -252,7 +252,7 @@ restart:
ilog(LOG_DEBUG, "SSRC hash table exceeded size limit (trying to add %s%x%s) - "
"deleting SSRC %s%x%s",
FMT_M(ssrc), FMT_M(old_ent->ssrc));
g_atomic_pointer_set(&ht->cache, NULL);
atomic_set(&ht->cache, NULL);
g_hash_table_remove(ht->ht, &old_ent->ssrc); // does obj_put
obj_put(old_ent); // for the queue entry
}
@ -261,12 +261,13 @@ restart:
// preempted
rwlock_unlock_w(&ht->lock);
// return created entry if slot is still empty
if (!g_atomic_pointer_compare_and_exchange(&ht->precreat, NULL, ent))
struct ssrc_entry *null_entry = NULL;
if (!atomic_compare_exchange(&ht->precreat, &null_entry, ent))
obj_put(ent);
goto restart;
}
add_ssrc_entry(ssrc, ent, ht);
g_atomic_pointer_set(&ht->cache, ent);
atomic_set(&ht->cache, ent);
rwlock_unlock_w(&ht->lock);
if (created)
*created = true;

@ -153,8 +153,7 @@ static struct bpool_shard *bufferpool_make_shard(struct bufferpool *bp) {
if (idx < bp->max_shards) {
// Attempt to insert. Slot must be empty
struct bpool_shard *expected = NULL;
if (!__atomic_compare_exchange_n(&bp->shards[idx], &expected, shard,
false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
if (!atomic_compare_exchange(&bp->shards[idx], &expected, shard))
continue; // Somebody beat us to it. Try again
// Success. Record the new count

Loading…
Cancel
Save