Introduce NEITHER_READ_NOR_WRITE in ctl.
This is slightly clearer in meaning. A function that is both READONLY() and WRITEONLY() is in fact neither one.
This commit is contained in:
parent
6a622867ca
commit
d92f0175c7
32
src/ctl.c
32
src/ctl.c
@ -1451,6 +1451,7 @@ ctl_mtx_assert_held(tsdn_t *tsdn) {
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
/* Can read or write, but not both. */
|
||||||
#define READ_XOR_WRITE() do { \
|
#define READ_XOR_WRITE() do { \
|
||||||
if ((oldp != NULL && oldlenp != NULL) && (newp != NULL || \
|
if ((oldp != NULL && oldlenp != NULL) && (newp != NULL || \
|
||||||
newlen != 0)) { \
|
newlen != 0)) { \
|
||||||
@ -1459,6 +1460,15 @@ ctl_mtx_assert_held(tsdn_t *tsdn) {
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
/* Can neither read nor write. */
|
||||||
|
#define NEITHER_READ_NOR_WRITE() do { \
|
||||||
|
if (oldp != NULL || oldlenp != NULL || newp != NULL || \
|
||||||
|
newlen != 0) { \
|
||||||
|
ret = EPERM; \
|
||||||
|
goto label_return; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define READ(v, t) do { \
|
#define READ(v, t) do { \
|
||||||
if (oldp != NULL && oldlenp != NULL) { \
|
if (oldp != NULL && oldlenp != NULL) { \
|
||||||
if (*oldlenp != sizeof(t)) { \
|
if (*oldlenp != sizeof(t)) { \
|
||||||
@ -1902,14 +1912,7 @@ thread_tcache_flush_ctl(tsd_t *tsd, const size_t *mib,
|
|||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
NEITHER_READ_NOR_WRITE();
|
||||||
* Slightly counterintuitively, READONLY() really just requires that the
|
|
||||||
* call isn't trying to write, and WRITEONLY() just requires that it
|
|
||||||
* isn't trying to read; hence, adding both requires that the operation
|
|
||||||
* is neither a read nor a write.
|
|
||||||
*/
|
|
||||||
READONLY();
|
|
||||||
WRITEONLY();
|
|
||||||
|
|
||||||
tcache_flush(tsd);
|
tcache_flush(tsd);
|
||||||
|
|
||||||
@ -1985,9 +1988,7 @@ thread_idle_ctl(tsd_t *tsd, const size_t *mib,
|
|||||||
size_t newlen) {
|
size_t newlen) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* See the comment in thread_tcache_flush_ctl. */
|
NEITHER_READ_NOR_WRITE();
|
||||||
READONLY();
|
|
||||||
WRITEONLY();
|
|
||||||
|
|
||||||
if (tcache_available(tsd)) {
|
if (tcache_available(tsd)) {
|
||||||
tcache_flush(tsd);
|
tcache_flush(tsd);
|
||||||
@ -2151,8 +2152,7 @@ arena_i_decay_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
|
|||||||
int ret;
|
int ret;
|
||||||
unsigned arena_ind;
|
unsigned arena_ind;
|
||||||
|
|
||||||
READONLY();
|
NEITHER_READ_NOR_WRITE();
|
||||||
WRITEONLY();
|
|
||||||
MIB_UNSIGNED(arena_ind, 1);
|
MIB_UNSIGNED(arena_ind, 1);
|
||||||
arena_i_decay(tsd_tsdn(tsd), arena_ind, false);
|
arena_i_decay(tsd_tsdn(tsd), arena_ind, false);
|
||||||
|
|
||||||
@ -2167,8 +2167,7 @@ arena_i_purge_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
|
|||||||
int ret;
|
int ret;
|
||||||
unsigned arena_ind;
|
unsigned arena_ind;
|
||||||
|
|
||||||
READONLY();
|
NEITHER_READ_NOR_WRITE();
|
||||||
WRITEONLY();
|
|
||||||
MIB_UNSIGNED(arena_ind, 1);
|
MIB_UNSIGNED(arena_ind, 1);
|
||||||
arena_i_decay(tsd_tsdn(tsd), arena_ind, true);
|
arena_i_decay(tsd_tsdn(tsd), arena_ind, true);
|
||||||
|
|
||||||
@ -2183,8 +2182,7 @@ arena_i_reset_destroy_helper(tsd_t *tsd, const size_t *mib, size_t miblen,
|
|||||||
arena_t **arena) {
|
arena_t **arena) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
READONLY();
|
NEITHER_READ_NOR_WRITE();
|
||||||
WRITEONLY();
|
|
||||||
MIB_UNSIGNED(*arena_ind, 1);
|
MIB_UNSIGNED(*arena_ind, 1);
|
||||||
|
|
||||||
*arena = arena_get(tsd_tsdn(tsd), *arena_ind, false);
|
*arena = arena_get(tsd_tsdn(tsd), *arena_ind, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user