summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Piechotka <uzytkownik2@gmail.com>2013-12-16 01:20:44 +0100
committerMaciej Piechotka <uzytkownik2@gmail.com>2013-12-16 01:20:44 +0100
commitdf6d40a3970edadba7f25f3b739ab64e31c05115 (patch)
tree67986c3927f9e1d001e65e418ec6315f4b436474
parent4da9e5e25596293634424ca78b322809338c2dd1 (diff)
downloadlibgee-df6d40a3970edadba7f25f3b739ab64e31c05115.tar.gz
Fix unused variable warnings for HazardPointer
-rw-r--r--gee/Makefile.am1
-rw-r--r--gee/concurrentlist.vala19
-rw-r--r--gee/concurrentset.vala40
-rw-r--r--utils/geeutils.vapi4
-rw-r--r--utils/misc.h30
5 files changed, 94 insertions, 0 deletions
diff --git a/gee/Makefile.am b/gee/Makefile.am
index b2fa6ac..a988d22 100644
--- a/gee/Makefile.am
+++ b/gee/Makefile.am
@@ -83,6 +83,7 @@ libgee_0_8_la_SOURCES = \
$(libgee_0_8_la_VALASOURCES:.vala=.c) \
../utils/async.h \
../utils/free.h \
+ ../utils/misc.h \
$(NULL)
libgee_0_8_la_DEPENDENCIES = \
diff --git a/gee/concurrentlist.vala b/gee/concurrentlist.vala
index c3137df..106f4db 100644
--- a/gee/concurrentlist.vala
+++ b/gee/concurrentlist.vala
@@ -65,6 +65,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
~ConcurrentList () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
_head = null;
HazardPointer.set_pointer<Node<G>?> (&_tail, null);
}
@@ -84,6 +85,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
public override int size {
get {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
int result = 0;
for (var iter = iterator (); iter.next ();)
result++;
@@ -105,6 +107,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
*/
public override bool contains (G item) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
for (var iter = iterator (); iter.next ();)
if (equal_func (item, iter.get ()))
return true;
@@ -116,6 +119,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
*/
public override bool add (G item) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Node<G> node = new Node<G> (item);
node.insert (get_tail (), null);
return true;
@@ -126,6 +130,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
*/
public override bool remove (G item) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Gee.Iterator<G> iter = iterator ();
while (iter.next ()) {
if (equal_func (item, iter.get ())) {
@@ -141,6 +146,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
*/
public override void clear () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
var iter = iterator ();
while (iter.next ())
iter.remove ();
@@ -166,6 +172,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
*/
public override G? get (int index) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
assert (index >= 0);
for (var iterator = iterator (); iterator.next ();)
if (index-- == 0)
@@ -178,6 +185,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
*/
public override void set (int index, G item) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
assert (index >= 0);
for (var iterator = list_iterator (); iterator.next ();) {
if (index-- == 0) {
@@ -193,6 +201,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
*/
public override int index_of (G item) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
int index = 0;
for (var iterator = list_iterator (); iterator.next (); index++)
if (equal_func (item, iterator.get ()))
@@ -205,6 +214,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
*/
public override void insert (int index, G item) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
assert (index >= 0);
if (index == 0) {
var prev = _head;
@@ -227,6 +237,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
*/
public override G remove_at (int index) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
for (var iterator = list_iterator (); iterator.next ();) {
if (index-- == 0) {
G data = iterator.get ();
@@ -242,6 +253,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
*/
public override List<G>? slice (int start, int end) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
assert (0 <= start);
assert (start <= end);
var list = new ConcurrentList<G>.with_closure (_equal_func);
@@ -282,6 +294,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
public bool next () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Node<G>? _old_prev = _removed ? _prev : null;
bool success = Node.proceed<G> (ref _prev, ref _curr);
if (success) {
@@ -295,6 +308,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
public bool has_next () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Node<G>? prev = _prev;
Node<G> curr = _curr;
return Node.proceed<G> (ref prev, ref curr);
@@ -302,12 +316,14 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
public new G get () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
assert (valid);
return HazardPointer.get_pointer<G> (&_curr._data);
}
public new void set (G item) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
assert (valid);
#if DEBUG
G item_copy = item;
@@ -320,6 +336,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
public void remove () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
assert (valid);
_curr.remove (_prev);
_removed = true;
@@ -342,6 +359,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
public void add (G item) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
assert (valid);
if (!Node.proceed<G> (ref _prev, ref _curr)) {
_prev = (owned)_curr;
@@ -355,6 +373,7 @@ public class Gee.ConcurrentList<G> : AbstractList<G> {
public new bool foreach (ForallFunc<G> f) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
if (_prev != null && !_removed) {
if (!f (HazardPointer.get_pointer<G> (&_curr._data))) {
return false;
diff --git a/gee/concurrentset.vala b/gee/concurrentset.vala
index c0b7b80..217c73a 100644
--- a/gee/concurrentset.vala
+++ b/gee/concurrentset.vala
@@ -38,6 +38,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
~ConcurrentSet () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
_head = null;
}
@@ -51,12 +52,14 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override bool contains (G key) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Tower<G> prev = _head;
return Tower.search<G> (_cmp, key, ref prev, null);
}
public override bool add (G key) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Rand *rnd = rand.get ();
if (rnd == null) {
rand.set (rnd = new Rand ());
@@ -80,6 +83,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override bool remove (G item) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
TowerIter<G> prev = TowerIter<G>();
for (int i = 0; i < _MAX_HEIGHT; i++) {
prev._iter[i] = _head;
@@ -93,6 +97,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override void clear () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Tower<G>? first;
while ((first = _head.get_next (0)) != null) {
remove (first._data);
@@ -101,6 +106,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override G first () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Tower<G>? prev = null;
Tower<G> curr = _head;
if (Tower.proceed<G> (_cmp, ref prev, ref curr, 0)) {
@@ -112,6 +118,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override G last () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Tower<G>? prev = null;
Tower<G> curr = _head;
bool found = false;
@@ -128,6 +135,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override Gee.Iterator<G>? iterator_at (G element) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
TowerIter<G> prev = TowerIter<G> ();
TowerIter<G> curr;
for (int i = 0; i < _MAX_HEIGHT; i++) {
@@ -141,6 +149,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override G? lower (G element) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Tower<G> prev = _head;
Tower.search<G> (_cmp, element, ref prev);
if (prev == _head) {
@@ -151,6 +160,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override G? higher (G element) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Tower<G> prev = _head;
Tower<G>? next;
if (Tower.search<G> (_cmp, element, ref prev, out next)) {
@@ -166,6 +176,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override G? floor (G element) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Tower<G> prev = _head;
Tower<G>? next;
if (Tower.search<G> (_cmp, element, ref prev, out next)) {
@@ -179,6 +190,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override G? ceil (G element) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Tower<G> prev = _head;
Tower<G>? next;
Tower.search<G> (_cmp, element, ref prev, out next);
@@ -190,15 +202,18 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override SortedSet<G> head_set (G before) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
return new SubSet<G> (new Range<G>.head (this, before));
}
public override SortedSet<G> tail_set (G after) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
return new SubSet<G> (new Range<G>.tail (this, after));
}
public override SortedSet<G> sub_set (G from, G to) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
return new SubSet<G> (new Range<G> (this, from, to));
}
@@ -256,6 +271,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public new bool foreach (ForallFunc<G> f) {
assert (_curr != null);
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
if (_prev._iter[0] != null && !_removed) {
if (!f (_curr._data)) {
assert (_curr != null);
@@ -287,6 +303,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public bool next () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Tower<G>? new_prev = _prev._iter[0];
Tower<G>? new_curr = _curr;
bool success = Tower.proceed<G> (_set._cmp, ref new_prev, ref new_curr, 0);
@@ -308,6 +325,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public bool has_next () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Tower<G> prev = _prev._iter[0];
Tower<G>? curr = _curr;
return Tower.proceed<G> (_set._cmp, ref prev, ref curr, 0);
@@ -320,6 +338,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public void remove () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
assert (valid);
if (Tower.remove<G> (_set._cmp, ref _prev, _curr)) {
AtomicInt.dec_and_test (ref _set._size);
@@ -341,6 +360,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override int size {
get {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Tower<G>? curr;
Range.improve_bookmark<G> (_range, out curr);
if (curr != null) {
@@ -359,6 +379,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public bool is_empty {
get {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Tower<G>? curr;
Range.improve_bookmark<G> (_range, out curr);
return curr != null;
@@ -373,11 +394,13 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override Gee.Iterator<G> iterator () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
return new SubIterator<G> (_range);
}
public override bool contains (G item) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
if (!Range.inside<G> (_range, item)) {
return false;
}
@@ -388,6 +411,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override bool add (G key) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
if (!Range.inside<G> (_range, key)) {
return false;
}
@@ -414,6 +438,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override bool remove (G key) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
if (!Range.inside<G> (_range, key)) {
return false;
}
@@ -429,6 +454,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override void clear () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
TowerIter<G> prev;
Tower<G>? first;
Range.improve_bookmark<G> (_range, out first, out prev);
@@ -440,6 +466,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override G? first () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
Tower<G>? first;
Range.improve_bookmark<G> (_range, out first);
if (first == null) {
@@ -450,6 +477,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override G? last () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
TowerIter<G> prev;
Range.improve_bookmark<G> (_range, null, out prev);
Tower<G>? curr = null;
@@ -477,6 +505,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override Gee.Iterator<G>? iterator_at (G element) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
if (!Range.inside<G> (_range, element)) {
return null;
}
@@ -491,6 +520,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override G? lower (G element) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
switch (Range.cmp<G> (_range, element)) {
case Range.Position.BEFORE:
case Range.Position.EMPTY:
@@ -512,6 +542,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override G? higher (G element) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
switch (Range.cmp<G> (_range, element)) {
case Range.Position.BEFORE:
return first ();
@@ -538,6 +569,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override G? floor (G element) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
switch (Range.cmp<G> (_range, element)) {
case Range.Position.BEFORE:
case Range.Position.EMPTY:
@@ -562,6 +594,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override G? ceil (G element) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
switch (Range.cmp<G> (_range, element)) {
case Range.Position.BEFORE:
return first ();
@@ -584,16 +617,19 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public override SortedSet<G> head_set (G before) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
return new SubSet<G> (Range.cut_tail (_range, before));
}
public override SortedSet<G> tail_set (G after) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
return new SubSet<G> (Range.cut_head (_range, after));
}
public override SortedSet<G> sub_set (G from, G to) {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
return new SubSet<G> (Range.cut (_range, from, to));
}
@@ -616,6 +652,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public new bool foreach (ForallFunc<G> f) {
assert (_curr != null);
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
if (!begin ()) {
return true;
}
@@ -650,6 +687,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public bool next () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
if (_prev._iter[0] == null) {
return begin ();
} else {
@@ -675,6 +713,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public bool has_next () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
if (_prev._iter[0] == null) {
Tower<G> next;
Range.improve_bookmark<G> (_range, out next);
@@ -696,6 +735,7 @@ public class Gee.ConcurrentSet<G> : AbstractSortedSet<G> {
public void remove () {
HazardPointer.Context ctx = new HazardPointer.Context ();
+ Utils.Misc.unused (ctx);
assert (valid);
if (Tower.remove<G> (_range._set._cmp, ref _prev, _curr)) {
AtomicInt.dec_and_test (ref _range._set._size);
diff --git a/utils/geeutils.vapi b/utils/geeutils.vapi
index f7d5de6..988a337 100644
--- a/utils/geeutils.vapi
+++ b/utils/geeutils.vapi
@@ -8,5 +8,9 @@ namespace Gee {
[CCode (cheader_filename = "free.h")]
public GLib.DestroyNotify get_destroy_notify<G> ();
}
+ namespace Misc {
+ [CCode (cheader_filename = "misc.h", simple_generics = true)]
+ public void unused<G> (G unused);
+ }
}
}
diff --git a/utils/misc.h b/utils/misc.h
new file mode 100644
index 0000000..9584058
--- /dev/null
+++ b/utils/misc.h
@@ -0,0 +1,30 @@
+/* async.h
+ *
+ * Copyright (C) 2013 Maciej Piechotka
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Maciej Piechotka <uzytkownik2@gmail.com>
+ */
+#ifndef GEE_UTILS_MISC
+#define GEE_UTILS_MISC
+
+#include <glib.h>
+
+#define gee_utils_misc_unused(par) (void)par
+
+#endif
+