Files
hakmem/core/tiny_sticky.h

27 lines
932 B
C
Raw Permalink Normal View History

// tiny_sticky.h - Sticky TLS Active box
#pragma once
#include <stdint.h>
#include "hakmem_tiny.h"
#include "hakmem_tiny_superslab.h"
#ifndef TINY_STICKY_RING
#define TINY_STICKY_RING 3
#endif
// TLS sticky rings (exported for existing call sites)
extern __thread SuperSlab* g_tls_sticky_ss[TINY_NUM_CLASSES][TINY_STICKY_RING];
extern __thread uint8_t g_tls_sticky_idx[TINY_NUM_CLASSES][TINY_STICKY_RING];
extern __thread uint8_t g_tls_sticky_pos[TINY_NUM_CLASSES];
static inline void tiny_sticky_clear(int class_idx, int slot) {
g_tls_sticky_ss[class_idx][slot] = NULL;
g_tls_sticky_idx[class_idx][slot] = 0;
}
static inline void tiny_sticky_save(int class_idx, SuperSlab* ss, uint8_t slab_idx) {
uint8_t pos = g_tls_sticky_pos[class_idx];
g_tls_sticky_ss[class_idx][pos] = ss;
g_tls_sticky_idx[class_idx][pos] = slab_idx;
g_tls_sticky_pos[class_idx] = (uint8_t)((pos + 1u) % TINY_STICKY_RING);
}