Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/synch/spinlock.h

    r78de83de r05882233  
    3636#define KERN_SPINLOCK_H_
    3737
     38#include <stdbool.h>
     39#include <barrier.h>
    3840#include <assert.h>
    39 #include <stdatomic.h>
    40 #include <stdbool.h>
    4141#include <preemption.h>
     42#include <atomic.h>
    4243#include <arch/asm.h>
    4344
     
    4546
    4647typedef struct spinlock {
    47         atomic_flag flag;
     48        atomic_t val;
    4849
    4950#ifdef CONFIG_DEBUG_SPINLOCK
     
    6970        spinlock_t lock_name = { \
    7071                .name = desc_name, \
    71                 .flag = ATOMIC_FLAG_INIT \
     72                .val = { 0 } \
    7273        }
    7374
     
    7576        static spinlock_t lock_name = { \
    7677                .name = desc_name, \
    77                 .flag = ATOMIC_FLAG_INIT \
     78                .val = { 0 } \
    7879        }
    7980
     
    8889#define SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
    8990        spinlock_t lock_name = { \
    90                 .flag = ATOMIC_FLAG_INIT \
     91                .val = { 0 } \
    9192        }
    9293
    9394#define SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \
    9495        static spinlock_t lock_name = { \
    95                 .flag = ATOMIC_FLAG_INIT \
     96                .val = { 0 } \
    9697        }
    9798
     
    125126NO_TRACE static inline void spinlock_unlock_nondebug(spinlock_t *lock)
    126127{
    127         atomic_flag_clear_explicit(&lock->flag, memory_order_release);
     128        /*
     129         * Prevent critical section code from bleeding out this way down.
     130         */
     131        CS_LEAVE_BARRIER();
     132
     133        atomic_set(&lock->val, 0);
    128134        preemption_enable();
    129135}
     
    209215                .lock = { \
    210216                        .name = desc_name, \
    211                         .flag = ATOMIC_FLAG_INIT \
     217                        .val = { 0 } \
    212218                }, \
    213219                .guard = false, \
     
    219225                .lock = { \
    220226                        .name = desc_name, \
    221                         .flag = ATOMIC_FLAG_INIT \
     227                        .val = { 0 } \
    222228                }, \
    223229                .guard = false, \
     
    230236        irq_spinlock_t lock_name = { \
    231237                .lock = { \
    232                         .flag = ATOMIC_FLAG_INIT \
     238                        .val = { 0 } \
    233239                }, \
    234240                .guard = false, \
     
    239245        static irq_spinlock_t lock_name = { \
    240246                .lock = { \
    241                         .flag = ATOMIC_FLAG_INIT \
     247                        .val = { 0 } \
    242248                }, \
    243249                .guard = false, \
Note: See TracChangeset for help on using the changeset viewer.