// Update the count if we were the one that completed the copy.
if (old_ht2_ent_val == DOES_NOT_EXIST) {
TRACE("h0", "hti_copy_entry: key %p value %p copied to new entry", key, ht1_ent_val);
- SYNC_ADD(&ht1->count, -1);
- SYNC_ADD(&ht2->count, 1);
+ (void)SYNC_ADD(&ht1->count, -1);
+ (void)SYNC_ADD(&ht2->count, 1);
return TRUE;
}
if (ent_val != COPIED_VALUE && ent_val != TAG_VALUE(TOMBSTONE, TAG1)) {
int did_copy = hti_copy_entry(hti, ent, key_hash, ((volatile hti_t *)hti)->next);
if (did_copy) {
- SYNC_ADD(&hti->num_entries_copied, 1);
+ (void)SYNC_ADD(&hti->num_entries_copied, 1);
}
TRACE("h0", "hti_cas: value in the middle of a copy, copy completed by %s",
(did_copy ? "self" : "other"), 0);
// The set succeeded. Adjust the value count.
if (old_existed && new == DOES_NOT_EXIST) {
- SYNC_ADD(&hti->count, -1);
+ (void)SYNC_ADD(&hti->count, -1);
} else if (!old_existed && new != DOES_NOT_EXIST) {
- SYNC_ADD(&hti->count, 1);
+ (void)SYNC_ADD(&hti->count, 1);
}
// Return the previous value.
if (EXPECT_FALSE(ent_val != COPIED_VALUE && ent_val != TAG_VALUE(TOMBSTONE, TAG1))) {
int did_copy = hti_copy_entry(hti, ent, key_hash, ((volatile hti_t *)hti)->next);
if (did_copy) {
- SYNC_ADD(&hti->num_entries_copied, 1);
+ (void)SYNC_ADD(&hti->num_entries_copied, 1);
}
}
return hti_get(((volatile hti_t *)hti)->next, key, key_hash); // tail-call
return region;
}
-__attribute__ ((constructor(101))) void mem_init (void) {
+void mem_init (void) {
#ifdef USE_SYSTEM_MALLOC
return;
#endif
assert(id < MAX_NUM_THREADS);
if (pending_[id] == NULL) {
pending_[id] = fifo_alloc(RCU_QUEUE_SCALE);
- SYNC_ADD(&num_threads_, 1);
+ (void)SYNC_ADD(&num_threads_, 1);
}
}
#include "runtime.h"
#include "tls.h"
+void mem_init (void);
+
void rcu_thread_init (int thread_id);
void lwt_thread_init (int thread_id);
void *restrict arg;
} thread_info_t;
-__attribute__ ((constructor(102))) void nbd_init (void) {
+__attribute__ ((constructor)) void nbd_init (void) {
//sranddev();
INIT_THREAD_LOCAL(rand_seed_);
INIT_THREAD_LOCAL(tid_);
SET_THREAD_LOCAL(tid_, 0);
+ mem_init();
lwt_thread_init(0);
rcu_thread_init(0);
}
haz_t *hp0 = haz_get_static(0);
// Wait for all the worker threads to be ready.
- __sync_fetch_and_add(&wait_, -1);
+ (void)__sync_fetch_and_add(&wait_, -1);
do {} while (wait_);
int i;
void *worker (void *arg) {
// Wait for all the worker threads to be ready.
- SYNC_ADD(&wait_, -1);
+ (void)SYNC_ADD(&wait_, -1);
do {} while (wait_);
#ifdef TEST_STRING_KEYS
int d = wd->id;
int iters = 10000;
- SYNC_ADD(wd->wait, -1);
+ (void)SYNC_ADD(wd->wait, -1);
do { } while (*wd->wait); // wait for all workers to be ready
map_key_t key;
unsigned int rand_seed = (unsigned int)id + 1;
// Wait for all the worker threads to be ready.
- __sync_fetch_and_add(&wait_, -1);
+ (void)__sync_fetch_and_add(&wait_, -1);
do {} while (wait_);
int i;
static txn_state_e txn_validate (txn_t *txn);
+static skiplist_t *active_ = NULL;
+
static version_t version_ = 1;
-static skiplist_t *active_ = NULL;
+static inline skiplist_t *get_active (void) {
-__attribute__ ((constructor(103))) void txn_init (void) {
- active_ = sl_alloc(NULL);
+ return active_;
}
// Validate the updates for <key>. Validation fails if there is a write-write conflict. That is if after our
case TXN_VALIDATING:
if (txn->wv == UNDETERMINED_VERSION) {
version_t wv = SYNC_ADD(&version_, 1);
- SYNC_CAS(&txn->wv, UNDETERMINED_VERSION, wv);
+ (void)SYNC_CAS(&txn->wv, UNDETERMINED_VERSION, wv);
}
for (i = 0; i < txn->writes_count; ++i) {
txn->map = map;
txn->writes = nbd_malloc(sizeof(*txn->writes) * INITIAL_WRITES_SIZE);
txn->writes_size = INITIAL_WRITES_SIZE;
+ if (EXPECT_FALSE(active_ == NULL)) {
+ skiplist_t *a = sl_alloc(NULL);
+ if (SYNC_CAS(&active_, NULL, a) != NULL) {
+ sl_free(a);
+ }
+ }
// acquire the read version for txn. must be careful to avoid a race
do {