Changeset 508b0df1 in mainline for uspace/lib/c/generic/thread/futex.c


Ignore:
Timestamp:
2018-09-06T20:21:52Z (6 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
78de83de, fc10e1b
Parents:
4621d23
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-13 03:53:39)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-09-06 20:21:52)
Message:

Remove uspace <atomic.h>, use <stdatomic.h> instead

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/thread/futex.c

    r4621d23 r508b0df1  
    3434
    3535#include <assert.h>
    36 #include <atomic.h>
     36#include <stdatomic.h>
    3737#include <fibril.h>
    3838#include <io/kio.h>
     
    5252void futex_initialize(futex_t *futex, int val)
    5353{
    54         atomic_set(&futex->val, val);
     54        atomic_store_explicit(&futex->val, val, memory_order_relaxed);
    5555}
    5656
     
    5959void __futex_assert_is_locked(futex_t *futex, const char *name)
    6060{
    61         void *owner = __atomic_load_n(&futex->owner, __ATOMIC_RELAXED);
     61        void *owner = atomic_load_explicit(&futex->owner, memory_order_relaxed);
    6262        fibril_t *self = (fibril_t *) fibril_get_id();
    6363        if (owner != self) {
     
    6969void __futex_assert_is_not_locked(futex_t *futex, const char *name)
    7070{
    71         void *owner = __atomic_load_n(&futex->owner, __ATOMIC_RELAXED);
     71        void *owner = atomic_load_explicit(&futex->owner, memory_order_relaxed);
    7272        fibril_t *self = (fibril_t *) fibril_get_id();
    7373        if (owner == self) {
     
    9191        futex_down(futex);
    9292
    93         void *prev_owner = __atomic_load_n(&futex->owner, __ATOMIC_RELAXED);
     93        void *prev_owner = atomic_load_explicit(&futex->owner,
     94            memory_order_relaxed);
    9495        assert(prev_owner == NULL);
    95         __atomic_store_n(&futex->owner, self, __ATOMIC_RELAXED);
     96        atomic_store_explicit(&futex->owner, self, memory_order_relaxed);
    9697}
    9798
     
    101102        DPRINTF("Unlocking futex %s (%p) by fibril %p.\n", name, futex, self);
    102103        __futex_assert_is_locked(futex, name);
    103         __atomic_store_n(&futex->owner, NULL, __ATOMIC_RELAXED);
     104        atomic_store_explicit(&futex->owner, NULL, memory_order_relaxed);
    104105        futex_up(futex);
    105106}
     
    110111        bool success = futex_trydown(futex);
    111112        if (success) {
    112                 void *owner = __atomic_load_n(&futex->owner, __ATOMIC_RELAXED);
     113                void *owner = atomic_load_explicit(&futex->owner,
     114                    memory_order_relaxed);
    113115                assert(owner == NULL);
    114116
    115                 __atomic_store_n(&futex->owner, self, __ATOMIC_RELAXED);
     117                atomic_store_explicit(&futex->owner, self, memory_order_relaxed);
    116118
    117119                DPRINTF("Trylock on futex %s (%p) by fibril %p succeeded.\n", name, futex, self);
     
    130132
    131133        __futex_assert_is_locked(futex, name);
    132         __atomic_store_n(&futex->owner, new_owner, __ATOMIC_RELAXED);
     134        atomic_store_explicit(&futex->owner, new_owner, memory_order_relaxed);
    133135}
    134136
Note: See TracChangeset for help on using the changeset viewer.