提交 bd01691d 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

operator new & delete for klockstat

上级 8d4b3ab5
...@@ -28,6 +28,9 @@ struct klockstat : public rcu_freed { ...@@ -28,6 +28,9 @@ struct klockstat : public rcu_freed {
klockstat(const char *name); klockstat(const char *name);
virtual void do_gc() { delete this; } virtual void do_gc() { delete this; }
static void* operator new(unsigned long nbytes);
static void operator delete(void *p);
}; };
#else #else
struct klockstat; struct klockstat;
......
...@@ -19,6 +19,19 @@ mylockstat(struct spinlock *lk) ...@@ -19,6 +19,19 @@ mylockstat(struct spinlock *lk)
{ {
return &lk->stat->s.cpu[cpunum()]; return &lk->stat->s.cpu[cpunum()];
} }
void*
klockstat::operator new(unsigned long nbytes)
{
assert(nbytes == sizeof(klockstat));
return kmalloc(sizeof(klockstat));
}
void
klockstat::operator delete(void *p)
{
return kmfree(p, sizeof(klockstat));
}
#endif #endif
static inline void static inline void
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论