Cold path. Sets the leaf entry for `base` to `val` (page to register, NULL to * unregister), allocating intermediate tables on demand. Returns false only if * a needed table allocation fails while registering. */
| 166 | * unregister), allocating intermediate tables on demand. Returns false only if |
| 167 | * a needed table allocation fails while registering. */ |
| 168 | static bool slab_map_set(uintptr_t base, slab_page_t *val) { |
| 169 | size_t i1, i2, i3; |
| 170 | if (!slab_map_indices(base, &i1, &i2, &i3)) { |
| 171 | return false; |
| 172 | } |
| 173 | slab_map_lock(); |
| 174 | slab_map_l2_t *l2 = atomic_load_explicit(&g_slab_map_root[i1], memory_order_relaxed); |
| 175 | if (!l2) { |
| 176 | if (!val) { |
| 177 | slab_map_unlock(); |
| 178 | return true; /* nothing to unregister */ |
| 179 | } |
| 180 | l2 = (slab_map_l2_t *)calloc(1, sizeof(*l2)); |
| 181 | if (!l2) { |
| 182 | slab_map_unlock(); |
| 183 | return false; |
| 184 | } |
| 185 | atomic_store_explicit(&g_slab_map_root[i1], l2, memory_order_release); |
| 186 | } |
| 187 | slab_map_l3_t *l3 = atomic_load_explicit(&l2->e[i2], memory_order_relaxed); |
| 188 | if (!l3) { |
| 189 | if (!val) { |
| 190 | slab_map_unlock(); |
| 191 | return true; |
| 192 | } |
| 193 | l3 = (slab_map_l3_t *)calloc(1, sizeof(*l3)); |
| 194 | if (!l3) { |
| 195 | slab_map_unlock(); |
| 196 | return false; |
| 197 | } |
| 198 | atomic_store_explicit(&l2->e[i2], l3, memory_order_release); |
| 199 | } |
| 200 | atomic_store_explicit(&l3->e[i3], val, memory_order_release); |
| 201 | slab_map_unlock(); |
| 202 | return true; |
| 203 | } |
| 204 | |
| 205 | /* ── Tier 1 helpers ────────────────────────────────────────────────── */ |
| 206 |
no test coverage detected