Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset d51cca8 in mainline for uspace/lib/c/include/barrier.h


Ignore:
Timestamp:
2018-09-06T17:20:15Z (3 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master
Children:
7328ff4
Parents:
f8048d1
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-11 22:57:32)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-09-06 17:20:15)
Message:

Use <stdatomic.h> to implement uspace barriers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/barrier.h

    rf8048d1 rd51cca8  
    3636#define LIBC_COMPILER_BARRIER_H_
    3737
    38 #include <libarch/barrier.h>
     38#include <stdatomic.h>
    3939
    4040extern void smp_memory_barrier(void);
    4141
    42 #define compiler_barrier() asm volatile ("" ::: "memory")
     42static inline void compiler_barrier(void)
     43{
     44        atomic_signal_fence(memory_order_seq_cst);
     45}
     46
     47static inline void memory_barrier(void)
     48{
     49        atomic_thread_fence(memory_order_seq_cst);
     50}
     51
     52static inline void read_barrier(void)
     53{
     54        atomic_thread_fence(memory_order_acquire);
     55}
     56
     57static inline void write_barrier(void)
     58{
     59        atomic_thread_fence(memory_order_release);
     60}
    4361
    4462/** Forces the compiler to access (ie load/store) the variable only once. */
Note: See TracChangeset for help on using the changeset viewer.