]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Portability fixes for Atomic::WordT API.
authorDmitry Kurochkin <dmitry.kurochkin@measurement-factory.com>
Fri, 28 Oct 2011 01:11:23 +0000 (19:11 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 28 Oct 2011 01:11:23 +0000 (19:11 -0600)
Change parameter types for swap_if() and operator==() from int to
Value.  This fixes some GCC warnings in "fake" implementation when
the AtomicWordT template parameter is unsigned.

Polished (waitingToBeFreed == true) test. waitingToBeFreed is
Atomic::WordT<uint8_t> and GCC does not know whether to cast AtomicWord or
boolean when comparing the two.

src/ipc/AtomicWord.h
src/ipc/StoreMap.cc

index 7a8eb1f984902a157b0f6ade3ed4ca7a89d7ff0b..e93c8ebee0caf694fbd1a9fda07a38fea23afada 100644 (file)
@@ -35,13 +35,13 @@ public:
     Value operator ++(int) { return __sync_fetch_and_add(&value, 1); }
     Value operator --(int) { return __sync_fetch_and_sub(&value, 1); }
 
-    bool swap_if(const int comparand, const int replacement) { return __sync_bool_compare_and_swap(&value, comparand, replacement); }
+    bool swap_if(const Value comparand, const Value replacement) { return __sync_bool_compare_and_swap(&value, comparand, replacement); }
 
     /// v1 = value; value &= v2; return v1;
     Value fetchAndAnd(const Value v2) { return __sync_fetch_and_and(&value, v2); }
 
     // TODO: no need for __sync_bool_compare_and_swap here?
-    bool operator ==(int v2) { return __sync_bool_compare_and_swap(&value, v2, value); }
+    bool operator ==(const Value v2) { return __sync_bool_compare_and_swap(&value, v2, value); }
 
     // TODO: no need for __sync_fetch_and_add here?
     Value get() const { return __sync_fetch_and_add(const_cast<Value*>(&value), 0); }
@@ -71,7 +71,7 @@ public:
     Value operator ++(int) { assert(Enabled()); return value++; }
     Value operator --(int) { assert(Enabled()); return value--; }
 
-    bool swap_if(const int comparand, const int replacement)
+    bool swap_if(const Value comparand, const Value replacement)
     { assert(Enabled()); return value == comparand ? value = replacement, true : false; }
 
     /// v1 = value; value &= v2; return v1;
@@ -79,7 +79,7 @@ public:
     { assert(Enabled()); const Value v1 = value; value &= v2; return v1; }
 
     // TODO: no need for __sync_bool_compare_and_swap here?
-    bool operator ==(const int v2) { assert(Enabled()); return value == v2; }
+    bool operator ==(const Value v2) { assert(Enabled()); return value == v2; }
 
     // TODO: no need for __sync_fetch_and_add here?
     Value get() const { assert(Enabled()); return value; }
index 530edcf728f1c32167977ca43630a5e233becbe7..f91b522bd29d05123f344e76e34ea5a699f3a16b 100644 (file)
@@ -46,7 +46,7 @@ Ipc::StoreMap::openForWriting(const cache_key *const key, sfileno &fileno)
         assert(s.state != Slot::Writeable); // until we start breaking locks
 
         // free if the entry was used, keeping the entry locked
-        if (s.waitingToBeFreed == true || s.state == Slot::Readable)
+        if (s.waitingToBeFreed || s.state == Slot::Readable)
             freeLocked(s, true);
 
         assert(s.state == Slot::Empty);