Commit c153c932 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Lasse Karstensen

Make it possible to creat LCK classes at runtime.

Use the hash_classic class as proof of concept
parent c9debc78
......@@ -831,6 +831,8 @@ int Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double);
#define Lck_Trylock(a) Lck__Trylock(a, __func__, __LINE__)
#define Lck_AssertHeld(a) Lck__Assert(a, 1)
struct VSC_C_lck *Lck_CreateClass(const char *name);
#define LOCK(nam) extern struct VSC_C_lck *lck_##nam;
#include "tbl/locks.h"
#undef LOCK
......
......@@ -212,6 +212,7 @@ Lck__New(struct lock *lck, struct VSC_C_lck *st, const char *w)
struct ilck *ilck;
AN(st);
AN(w);
AZ(lck->priv);
ALLOC_OBJ(ilck, ILCK_MAGIC);
AN(ilck);
......@@ -234,6 +235,13 @@ Lck_Delete(struct lock *lck)
FREE_OBJ(ilck);
}
struct VSC_C_lck *
Lck_CreateClass(const char *name)
{
return(VSM_Alloc(sizeof(struct VSC_C_lck),
VSC_CLASS, VSC_type_lck, name));
}
#define LOCK(nam) struct VSC_C_lck *lck_##nam;
#include "tbl/locks.h"
#undef LOCK
......@@ -246,9 +254,7 @@ LCK_Init(void)
#if !defined(__APPLE__) && !defined(__MACH__)
AZ(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK));
#endif
#define LOCK(nam) \
lck_##nam = VSM_Alloc(sizeof(struct VSC_C_lck), \
VSC_CLASS, VSC_type_lck, #nam);
#define LOCK(nam) lck_##nam = Lck_CreateClass(#nam);
#include "tbl/locks.h"
#undef LOCK
}
......@@ -38,6 +38,8 @@
#include "hash/hash_slinger.h"
static struct VSC_C_lck *lck_hcl;
/*--------------------------------------------------------------------*/
struct hcl_hd {
......@@ -90,6 +92,7 @@ hcl_start(void)
{
unsigned u;
lck_hcl = Lck_CreateClass("hcl");
hcl_head = calloc(sizeof *hcl_head, hcl_nhash);
XXXAN(hcl_head);
......
......@@ -35,7 +35,6 @@ LOCK(busyobj)
LOCK(cli)
LOCK(exp)
LOCK(hcb)
LOCK(hcl)
LOCK(hsl)
LOCK(lru)
LOCK(mempool)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment