]> pd.if.org Git - nbds/commitdiff
fix compiler warnings/error under gcc 4.1 and 4.2
authorjdybnis <jdybnis@9ec2166a-aeea-11dd-8830-69e4bb380a4a>
Mon, 19 Jan 2009 05:21:45 +0000 (05:21 +0000)
committerjdybnis <jdybnis@9ec2166a-aeea-11dd-8830-69e4bb380a4a>
Mon, 19 Jan 2009 05:21:45 +0000 (05:21 +0000)
map/hashtable.c
runtime/mem.c
runtime/rcu.c
runtime/rlocal.h
runtime/runtime.c
test/haz_test.c
test/map_test1.c
test/map_test2.c
test/rcu_test.c
txn/txn.c

index 231384c22cb626ac8f6e03ed8991cd7fcd719602..b8d8f6b3f3e5972837d13e746fed85b933955fb6 100644 (file)
@@ -288,8 +288,8 @@ static int hti_copy_entry (hti_t *ht1, volatile entry_t *ht1_ent, uint32_t key_h
     // 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;
     }
 
@@ -376,7 +376,7 @@ static map_val_t hti_cas (hti_t *hti, map_key_t key, uint32_t key_hash, map_val_
         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);
@@ -410,9 +410,9 @@ static map_val_t hti_cas (hti_t *hti, map_key_t key, uint32_t key_hash, map_val_
 
     // 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.
@@ -443,7 +443,7 @@ static map_val_t hti_get (hti_t *hti, map_key_t key, uint32_t key_hash) {
         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
index 1f7a5a6e769fdd0193e69baac6eb0ae8e1d2eea0..57d94aa59fe817aa3e88c5c8dc4dc4365639336a 100644 (file)
@@ -95,7 +95,7 @@ static void *get_new_region (int block_scale) {
     return region;
 }
 
-__attribute__ ((constructor(101))) void mem_init (void) {
+void mem_init (void) {
 #ifdef USE_SYSTEM_MALLOC
     return;
 #endif
index 3e74986ff025819cf1ac838a6498b32d70978716..0c491334c30acd71aa966986e323cc1d4ea6d403 100644 (file)
@@ -43,7 +43,7 @@ void rcu_thread_init (int id) {
     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);
     }
 }
 
index d6e90fac4b608fabb4eb6e41943e173f77174df7..bb62c76e260b98cf3b43b7a9834cfe69b12a653a 100644 (file)
@@ -4,6 +4,8 @@
 #include "runtime.h"
 #include "tls.h"
 
+void mem_init (void);
+
 void rcu_thread_init (int thread_id);
 void lwt_thread_init (int thread_id);
 
index b145faa872e5826ed70a979d724a561cdc24738a..ceb67729f79ba7e7518736cf9d6812607630520f 100644 (file)
@@ -20,11 +20,12 @@ typedef struct thread_info {
     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);
 }
index c55ad0ec2698c5afadd7eb31fcb20bee52802132..a84c7be6135447f2a8e38982fa071ddb08f925b8 100644 (file)
@@ -36,7 +36,7 @@ void *worker (void *arg) {
     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;
index 3acf4c2a43cac981110d6e46ff684bf57589f92f..ce6102ce0414a2d081716e3e76d7bb1765b9ebb5 100644 (file)
@@ -23,7 +23,7 @@ static map_t *map_;
 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
index b660c1ab94e1030ad694566ddf264c31cafa8111..b239cfc190cac1b0e7c4dc28b684cc8b6f8d9713 100644 (file)
@@ -138,7 +138,7 @@ void *add_remove_worker (void *arg) {
     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;
index 3fd10d5a60f4b785f784b914f16f9ec9b682c40e..518125379f58336ab4e19324491a815c5529d027 100644 (file)
@@ -57,7 +57,7 @@ void *worker (void *arg) {
     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;
index 20d058394fa0b3afc57e7838613c67083feccb07..69f3b55daa6f1d64abb9aa9e06c35bd581b2e18c 100644 (file)
--- a/txn/txn.c
+++ b/txn/txn.c
@@ -42,12 +42,13 @@ struct txn {
 
 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
@@ -124,7 +125,7 @@ static txn_state_e txn_validate (txn_t *txn) {
         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) {
@@ -168,6 +169,12 @@ txn_t *txn_begin (map_t *map) {
     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 {