Small fixes

This commit is contained in:
2026-10-18 21:20:50 +02:00
parent 32f1ff25f7
commit 692d67e3cf
10 changed files with 46 additions and 4 deletions
+2
View File
@@ -11,3 +11,5 @@ struct ident {
};
const struct ident* ident_kernel(void);
bool ident_in_group(const struct ident* identity, gid_t gid, bool use_real);
+1 -1
View File
@@ -10,7 +10,7 @@
type _sl_link; \
}
#define list_is_empty(head) ((head)->_sl_head == NULL)
#define list_is_empty(head) ((head)->_sl_head == nullptr)
#define list_first(head) ((head)->_sl_head)
#define list_next(elm, field) ((elm)->field._sl_link)
+9
View File
@@ -16,6 +16,15 @@ static inline void refcount_inc(struct refcount* rc) {
atomic_fetch_add(&rc->count, 1, ATOMIC_RELAXED);
}
static inline bool refcount_inc_not_zero(struct refcount* rc) {
size_t count = atomic_load(&rc->count, ATOMIC_RELAXED);
do {
if (count == 0)
return false;
} while (!atomic_compare_exchange_weak(&rc->count, &count, count + 1, ATOMIC_ACQUIRE, ATOMIC_RELAXED));
return true;
}
static inline bool refcount_dec(struct refcount* rc) {
if (atomic_fetch_sub(&rc->count, 1, ATOMIC_RELEASE) != 1)
return false;
+2
View File
@@ -14,5 +14,7 @@ void spin_init(struct spinlock* spin);
// Attempts to lock a spinlock. If it's already locked, waits until it's freed.
void spin_lock(struct spinlock* spin);
bool spin_trylock(struct spinlock* spin);
// Unlocks a spinlock.
void spin_unlock(struct spinlock* spin);