33 lines
913 B
C
33 lines
913 B
C
|
|
#ifndef HAKMEM_TINY_REGISTRY_API_H
|
||
|
|
#define HAKMEM_TINY_REGISTRY_API_H
|
||
|
|
|
||
|
|
#include <stdint.h>
|
||
|
|
#include <pthread.h>
|
||
|
|
|
||
|
|
// Forward declarations
|
||
|
|
struct TinySlab;
|
||
|
|
typedef struct TinySlab TinySlab;
|
||
|
|
|
||
|
|
// Phase 2B-3: Registry Operations API
|
||
|
|
// Hash table for slab ownership tracking
|
||
|
|
|
||
|
|
// Hash function for slab_base (64KB aligned) - static inline for cross-TU use
|
||
|
|
#ifndef SLAB_REGISTRY_MASK
|
||
|
|
#define SLAB_REGISTRY_MASK 0x7F // Assuming this is defined in hakmem_tiny.h
|
||
|
|
#endif
|
||
|
|
|
||
|
|
static inline int registry_hash(uintptr_t slab_base) {
|
||
|
|
return (slab_base >> 16) & SLAB_REGISTRY_MASK;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Register slab in hash table (returns 1 on success, 0 on failure)
|
||
|
|
int registry_register(uintptr_t slab_base, TinySlab* owner);
|
||
|
|
|
||
|
|
// Unregister slab from hash table
|
||
|
|
void registry_unregister(uintptr_t slab_base);
|
||
|
|
|
||
|
|
// Registry lock (extern from hakmem_tiny.c)
|
||
|
|
extern pthread_mutex_t g_tiny_registry_lock;
|
||
|
|
|
||
|
|
#endif // HAKMEM_TINY_REGISTRY_API_H
|