Changeset 4621d23 in mainline
- Timestamp:
- 2018-09-06T19:54:11Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 508b0df1
- Parents:
- ffa73c6
- git-author:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-13 03:00:17)
- git-committer:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-09-06 19:54:11)
- Files:
-
- 9 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
abi/include/_bits/native.h
rffa73c6 r4621d23 55 55 typedef __UINTPTR_TYPE__ sysarg_t; 56 56 typedef __INTPTR_TYPE__ native_t; 57 typedef __UINTPTR_TYPE__ atomic_count_t;58 typedef __INTPTR_TYPE__ atomic_signed_t;59 57 60 58 #define PRIdn __PRIdPTR__ /**< Format for native_t. */ 61 59 #define PRIun __PRIuPTR__ /**< Format for sysarg_t. */ 62 60 #define PRIxn __PRIxPTR__ /**< Format for hexadecimal sysarg_t. */ 63 #define PRIua __PRIuPTR__ /**< Format for atomic_count_t. */64 61 65 62 #endif -
kernel/arch/arm32/src/atomic.c
rffa73c6 r4621d23 36 36 #include <synch/spinlock.h> 37 37 #include <arch/barrier.h> 38 #include <arch/asm.h> 38 39 40 unsigned __atomic_fetch_add_4(volatile unsigned *mem, unsigned val, int model) 41 { 42 /* 43 * This implementation is for UP pre-ARMv6 systems where we do not have 44 * the LDREX and STREX instructions. 45 */ 46 ipl_t ipl = interrupts_disable(); 47 unsigned ret = *mem; 48 *mem += val; 49 interrupts_restore(ipl); 50 return ret; 51 } 52 53 unsigned __atomic_fetch_sub_4(volatile unsigned *mem, unsigned val, int model) 54 { 55 ipl_t ipl = interrupts_disable(); 56 unsigned ret = *mem; 57 *mem -= val; 58 interrupts_restore(ipl); 59 return ret; 60 } 39 61 40 62 IRQ_SPINLOCK_STATIC_INITIALIZE_NAME(cas_lock, "arm-cas-lock"); -
kernel/generic/include/atomic.h
rffa73c6 r4621d23 36 36 #define KERN_ATOMIC_H_ 37 37 38 #include <stdbool.h> 38 39 #include <typedefs.h> 39 #include <arch/atomic.h> 40 #include <verify.h> 40 #include <stdatomic.h> 41 41 42 NO_TRACE ATOMIC static inline void atomic_set(atomic_t *val, atomic_count_t i) 43 WRITES(&val->count) 44 REQUIRES_EXTENT_MUTABLE(val) 42 typedef size_t atomic_count_t; 43 typedef ssize_t atomic_signed_t; 44 45 #define PRIua "zu" /**< Format for atomic_count_t. */ 46 47 typedef struct { 48 volatile atomic_size_t count; 49 } atomic_t; 50 51 static inline void atomic_set(atomic_t *val, atomic_count_t i) 45 52 { 46 val->count = i;53 atomic_store(&val->count, i); 47 54 } 48 55 49 NO_TRACE ATOMIC static inline atomic_count_t atomic_get(atomic_t *val) 50 REQUIRES_EXTENT_MUTABLE(val) 56 static inline atomic_count_t atomic_get(atomic_t *val) 51 57 { 52 return val->count;58 return atomic_load(&val->count); 53 59 } 54 60 61 static inline size_t atomic_predec(atomic_t *val) 62 { 63 return atomic_fetch_sub(&val->count, 1) - 1; 64 } 55 65 56 /* 57 * If the architecture does not provide operations that are atomic 58 * only with respect to the local cpu (eg exception handlers) and 59 * not other cpus, implement these cpu local atomic operations with 60 * full blown smp-safe atomics. 61 */ 62 #ifndef local_atomic_exchange 66 static inline size_t atomic_preinc(atomic_t *val) 67 { 68 return atomic_fetch_add(&val->count, 1) + 1; 69 } 70 71 static inline size_t atomic_postdec(atomic_t *val) 72 { 73 return atomic_fetch_sub(&val->count, 1); 74 } 75 76 static inline size_t atomic_postinc(atomic_t *val) 77 { 78 return atomic_fetch_add(&val->count, 1); 79 } 80 81 static inline void atomic_dec(atomic_t *val) 82 { 83 atomic_fetch_sub(&val->count, 1); 84 } 85 86 static inline void atomic_inc(atomic_t *val) 87 { 88 atomic_fetch_add(&val->count, 1); 89 } 90 63 91 #define local_atomic_exchange(var_addr, new_val) \ 64 __atomic_exchange_n((var_addr), (new_val), __ATOMIC_RELAXED) 65 #endif 92 atomic_exchange_explicit(var_addr, new_val, memory_order_relaxed) 66 93 94 static inline bool test_and_set(atomic_t *val) 95 { 96 return atomic_exchange(&val->count, 1); 97 } 67 98 68 99 -
kernel/generic/include/typedefs.h
rffa73c6 r4621d23 39 39 #include <_bits/errno.h> 40 40 41 typedef struct {42 volatile atomic_count_t count;43 } atomic_t;44 45 41 typedef void (*function)(void); 46 42 -
kernel/generic/include/verify.h
rffa73c6 r4621d23 39 39 #ifdef CONFIG_VERIFY_VCC 40 40 41 #define ATOMIC __specification_attr("atomic_inline", "")42 43 41 #define READS(ptr) __specification(reads(ptr)) 44 42 #define WRITES(ptr) __specification(writes(ptr)) … … 55 53 56 54 #else /* CONFIG_VERIFY_VCC */ 57 58 #define ATOMIC59 55 60 56 #define READS(ptr) -
kernel/generic/src/proc/scheduler.c
rffa73c6 r4621d23 40 40 41 41 #include <assert.h> 42 #include <atomic.h> 42 43 #include <proc/scheduler.h> 43 44 #include <proc/thread.h> -
uspace/lib/c/include/atomic.h
rffa73c6 r4621d23 42 42 typedef size_t atomic_count_t; 43 43 typedef ssize_t atomic_signed_t; 44 45 #define PRIua "zu" /**< Format for atomic_count_t. */ 44 46 45 47 typedef struct atomic {
Note:
See TracChangeset
for help on using the changeset viewer.