mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
Rename __zipos_free -> __zipos_drop (#1043)
Removes the separate decref function, uses keep/drop in the internal API.
This commit is contained in:
parent
fd772b9b2a
commit
5c35863524
4 changed files with 8 additions and 15 deletions
|
@ -39,7 +39,7 @@ int __zipos_close(int fd) {
|
||||||
if (!__vforked) {
|
if (!__vforked) {
|
||||||
struct ZiposHandle *h;
|
struct ZiposHandle *h;
|
||||||
h = (struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle;
|
h = (struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle;
|
||||||
__zipos_free(h);
|
__zipos_drop(h);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,18 +88,11 @@ struct ZiposHandle *__zipos_keep(struct ZiposHandle *h) {
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool __zipos_drop(struct ZiposHandle *h) {
|
void __zipos_drop(struct ZiposHandle *h) {
|
||||||
if (!atomic_fetch_sub_explicit(&h->refs, 1, memory_order_release)) {
|
if (atomic_fetch_sub_explicit(&h->refs, 1, memory_order_release)) {
|
||||||
atomic_thread_fence(memory_order_acquire);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void __zipos_free(struct ZiposHandle *h) {
|
|
||||||
if (!__zipos_drop(h)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
atomic_thread_fence(memory_order_acquire);
|
||||||
if (IsAsan()) {
|
if (IsAsan()) {
|
||||||
__asan_poison((char *)h + sizeof(struct ZiposHandle),
|
__asan_poison((char *)h + sizeof(struct ZiposHandle),
|
||||||
h->mapsize - sizeof(struct ZiposHandle), kAsanHeapFree);
|
h->mapsize - sizeof(struct ZiposHandle), kAsanHeapFree);
|
||||||
|
@ -227,7 +220,7 @@ static int __zipos_load(struct Zipos *zipos, size_t cf, int flags,
|
||||||
}
|
}
|
||||||
__fds_unlock();
|
__fds_unlock();
|
||||||
}
|
}
|
||||||
__zipos_free(h);
|
__zipos_drop(h);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +231,7 @@ void __zipos_postdup(int oldfd, int newfd) {
|
||||||
BLOCK_SIGNALS;
|
BLOCK_SIGNALS;
|
||||||
__fds_lock();
|
__fds_lock();
|
||||||
if (__isfdkind(newfd, kFdZip)) {
|
if (__isfdkind(newfd, kFdZip)) {
|
||||||
__zipos_free((struct ZiposHandle *)(intptr_t)g_fds.p[newfd].handle);
|
__zipos_drop((struct ZiposHandle *)(intptr_t)g_fds.p[newfd].handle);
|
||||||
if (!__isfdkind(oldfd, kFdZip)) {
|
if (!__isfdkind(oldfd, kFdZip)) {
|
||||||
bzero(g_fds.p + newfd, sizeof(*g_fds.p));
|
bzero(g_fds.p + newfd, sizeof(*g_fds.p));
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
.yoink __zipos_mmap
|
.yoink __zipos_mmap
|
||||||
.yoink __zipos_postdup
|
.yoink __zipos_postdup
|
||||||
.yoink __zipos_keep
|
.yoink __zipos_keep
|
||||||
.yoink __zipos_free
|
.yoink __zipos_drop
|
||||||
|
|
||||||
// TODO(jart): why does corruption happen when zip has no assets?
|
// TODO(jart): why does corruption happen when zip has no assets?
|
||||||
.yoink .cosmo
|
.yoink .cosmo
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct Zipos {
|
||||||
};
|
};
|
||||||
|
|
||||||
int __zipos_close(int);
|
int __zipos_close(int);
|
||||||
void __zipos_free(struct ZiposHandle *);
|
void __zipos_drop(struct ZiposHandle *);
|
||||||
struct ZiposHandle *__zipos_keep(struct ZiposHandle *);
|
struct ZiposHandle *__zipos_keep(struct ZiposHandle *);
|
||||||
struct Zipos *__zipos_get(void) pureconst;
|
struct Zipos *__zipos_get(void) pureconst;
|
||||||
size_t __zipos_normpath(char *, const char *, size_t);
|
size_t __zipos_normpath(char *, const char *, size_t);
|
||||||
|
|
Loading…
Reference in a new issue