atomic ptr
This commit is contained in:
parent
04eb118e60
commit
2c3597646d
@ -31,6 +31,9 @@ FORCE_INLINE u64 atomic_u64_eval_add(struct atomic_u64 *x, u64 a) { return _Inte
|
|||||||
FORCE_INLINE u64 atomic_u64_eval_exchange(struct atomic_u64 *x, u64 e) { return _InterlockedExchange64((volatile i64 *)&x->_v, e); }
|
FORCE_INLINE u64 atomic_u64_eval_exchange(struct atomic_u64 *x, u64 e) { return _InterlockedExchange64((volatile i64 *)&x->_v, e); }
|
||||||
FORCE_INLINE u64 atomic_u64_eval_compare_exchange(struct atomic_u64 *x, u64 c, u64 e) { return _InterlockedCompareExchange64((volatile i64 *)&x->_v, e, c); }
|
FORCE_INLINE u64 atomic_u64_eval_compare_exchange(struct atomic_u64 *x, u64 c, u64 e) { return _InterlockedCompareExchange64((volatile i64 *)&x->_v, e, c); }
|
||||||
|
|
||||||
|
FORCE_INLINE void *atomic_ptr_eval(struct atomic_ptr *x) { return (void *)_InterlockedExchangeAdd64((volatile i64 *)&x->_v, 0); }
|
||||||
|
FORCE_INLINE void *atomic_ptr_eval_compare_exchange(struct atomic_ptr *x, void *c, void *e) { return (void *)_InterlockedCompareExchange64((volatile i64 *)&x->_v, (i64)e, (i64)c); }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# error "Atomics not implemented"
|
# error "Atomics not implemented"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -308,6 +308,10 @@ struct atomic_u64 {
|
|||||||
volatile u64 _v;
|
volatile u64 _v;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct atomic_ptr {
|
||||||
|
volatile void *_v;
|
||||||
|
};
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Common structs
|
* Common structs
|
||||||
* ========================== */
|
* ========================== */
|
||||||
|
|||||||
@ -125,7 +125,7 @@ void _log(i32 level, struct string msg)
|
|||||||
ASSERT_INITIALIZED;
|
ASSERT_INITIALIZED;
|
||||||
|
|
||||||
if (level < 0 || level >= LOG_LEVEL_COUNT) {
|
if (level < 0 || level >= LOG_LEVEL_COUNT) {
|
||||||
sys_panic(STR("Invalid log level"));
|
sys_panic_raw("Invalid log level");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct temp_arena scratch = scratch_begin_no_conflict();
|
struct temp_arena scratch = scratch_begin_no_conflict();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user