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

try to live without operator->()

上级 9c16a4ba
...@@ -246,14 +246,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -246,14 +246,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return __pointer_type(_M_b); } { return __pointer_type(_M_b); }
__pointer_type __pointer_type
operator->() const
{ return __pointer_type(_M_b); }
__pointer_type
operator->() const volatile
{ return __pointer_type(_M_b); }
__pointer_type
operator=(__pointer_type __p) operator=(__pointer_type __p)
{ return _M_b.operator=(__p); } { return _M_b.operator=(__p); }
......
...@@ -228,11 +228,12 @@ inode::inode() ...@@ -228,11 +228,12 @@ inode::inode()
inode::~inode() inode::~inode()
{ {
if (dir) { auto d = dir.load();
dir->remove(strbuf<DIRSIZ>(".")); if (d) {
dir->remove(strbuf<DIRSIZ>("..")); d->remove(strbuf<DIRSIZ>("."));
gc_delayed(dir); d->remove(strbuf<DIRSIZ>(".."));
dir = 0; gc_delayed(d);
assert(cmpxch(&dir, d, (decltype(d)) 0));
} }
destroylock(&lock); destroylock(&lock);
...@@ -659,7 +660,7 @@ dir_flush(struct inode *dp) ...@@ -659,7 +660,7 @@ dir_flush(struct inode *dp)
return; return;
u32 off = 0; u32 off = 0;
dp->dir->enumerate([dp, &off](const strbuf<DIRSIZ> &name, const u32 &inum)->bool{ dp->dir.load()->enumerate([dp, &off](const strbuf<DIRSIZ> &name, const u32 &inum)->bool{
struct dirent de; struct dirent de;
strncpy(de.name, name._buf, DIRSIZ); strncpy(de.name, name._buf, DIRSIZ);
de.inum = inum; de.inum = inum;
...@@ -676,7 +677,7 @@ dirlookup(struct inode *dp, char *name) ...@@ -676,7 +677,7 @@ dirlookup(struct inode *dp, char *name)
{ {
dir_init(dp); dir_init(dp);
u32 inum = dp->dir->lookup(strbuf<DIRSIZ>(name)); u32 inum = dp->dir.load()->lookup(strbuf<DIRSIZ>(name));
//cprintf("dirlookup: %x (%d): %s -> %d\n", dp, dp->inum, name, inum); //cprintf("dirlookup: %x (%d): %s -> %d\n", dp, dp->inum, name, inum);
if (inum == 0) if (inum == 0)
...@@ -692,7 +693,7 @@ dirlink(struct inode *dp, const char *name, u32 inum) ...@@ -692,7 +693,7 @@ dirlink(struct inode *dp, const char *name, u32 inum)
dir_init(dp); dir_init(dp);
//cprintf("dirlink: %x (%d): %s -> %d\n", dp, dp->inum, name, inum); //cprintf("dirlink: %x (%d): %s -> %d\n", dp, dp->inum, name, inum);
return dp->dir->insert(strbuf<DIRSIZ>(name), inum); return dp->dir.load()->insert(strbuf<DIRSIZ>(name), inum);
} }
// Paths // Paths
......
...@@ -99,7 +99,7 @@ class xns : public rcu_freed { ...@@ -99,7 +99,7 @@ class xns : public rcu_freed {
u64 i = h(key); u64 i = h(key);
scoped_gc_epoch gc; scoped_gc_epoch gc;
auto e = table[i].chain; auto e = table[i].chain.load();
while (e) { while (e) {
if (e->key == key) if (e->key == key)
...@@ -153,7 +153,7 @@ class xns : public rcu_freed { ...@@ -153,7 +153,7 @@ class xns : public rcu_freed {
void enumerate(CB cb) { void enumerate(CB cb) {
scoped_gc_epoch gc; scoped_gc_epoch gc;
for (int i = 0; i < NHASH; i++) { for (int i = 0; i < NHASH; i++) {
auto e = table[i].chain; auto e = table[i].chain.load();
while (e) { while (e) {
if (cb(e->key, e->val)) if (cb(e->key, e->val))
return; return;
......
...@@ -183,7 +183,7 @@ isdirempty(struct inode *dp) ...@@ -183,7 +183,7 @@ isdirempty(struct inode *dp)
{ {
dir_init(dp); dir_init(dp);
int empty = 1; int empty = 1;
dp->dir->enumerate([&empty](const strbuf<DIRSIZ> &name, u64 ino)->bool{ dp->dir.load()->enumerate([&empty](const strbuf<DIRSIZ> &name, u64 ino)->bool{
if (!strcmp(name._buf, ".")) if (!strcmp(name._buf, "."))
return false; return false;
if (!strcmp(name._buf, "..")) if (!strcmp(name._buf, ".."))
...@@ -229,7 +229,7 @@ sys_unlink(void) ...@@ -229,7 +229,7 @@ sys_unlink(void)
} }
dir_init(dp); dir_init(dp);
if (dp->dir->remove(strbuf<DIRSIZ>(name), &ip->inum) == 0) { if (dp->dir.load()->remove(strbuf<DIRSIZ>(name), &ip->inum) == 0) {
iunlockput(ip); iunlockput(ip);
goto retry; goto retry;
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论