Change arena to use the atomic functions for ssize_t instead of the union strategy

This commit is contained in:
David Goldblatt 2017-03-06 11:41:29 -08:00 committed by David Goldblatt
parent 438efede78
commit 4f1e94658a
2 changed files with 3 additions and 12 deletions

View File

@ -36,11 +36,6 @@ struct arena_bin_info_s {
bitmap_info_t bitmap_info;
};
typedef union {
size_t u; /* Used for atomic operations. */
ssize_t s; /* Time may be negative (means "never"). */
} arena_decay_time_t;
struct arena_decay_s {
/* Synchronizes all non-atomic fields. */
malloc_mutex_t mtx;
@ -51,7 +46,7 @@ struct arena_decay_s {
*
* Synchronization: atomic.
*/
arena_decay_time_t time;
ssize_t time;
/* time / SMOOTHSTEP_NSTEPS. */
nstime_t interval;
/*

View File

@ -470,16 +470,12 @@ arena_extent_ralloc_large_expand(tsdn_t *tsdn, arena_t *arena, extent_t *extent,
static ssize_t
arena_decay_time_read(arena_t *arena) {
arena_decay_time_t dt;
dt.u = atomic_read_zu(&arena->decay.time.u);
return dt.s;
return atomic_read_zd(&arena->decay.time);
}
static void
arena_decay_time_write(arena_t *arena, ssize_t decay_time) {
arena_decay_time_t dt;
dt.s = decay_time;
atomic_write_zu(&arena->decay.time.u, dt.u);
atomic_write_zd(&arena->decay.time, decay_time);
}
static void