Spinlock save cpu flags

This commit is contained in:
2026-03-12 22:48:34 +01:00
parent 19793e9126
commit 4760818118
50 changed files with 704 additions and 461 deletions

View File

@@ -27,26 +27,30 @@ void id_alloc_fini (struct id_alloc* ida) {
}
int id_alloc (struct id_alloc* ida) {
spin_lock (&ida->lock);
uint64_t fid;
spin_lock (&ida->lock, &fid);
for (size_t bit = 0; bit < ida->bm.nbits; bit++) {
if (!bm_test (&ida->bm, bit)) {
bm_set (&ida->bm, bit);
spin_unlock (&ida->lock);
spin_unlock (&ida->lock, fid);
return (int)bit;
}
}
spin_unlock (&ida->lock);
spin_unlock (&ida->lock, fid);
return -ST_OOM_ERROR;
}
void id_free (struct id_alloc* ida, int id) {
uint64_t fid;
if (id < 0)
return;
spin_lock (&ida->lock);
spin_lock (&ida->lock, &fid);
bm_clear (&ida->bm, (size_t)id);
spin_unlock (&ida->lock);
spin_unlock (&ida->lock, fid);
}