Merge branch 'urcu/ht' into urcu/ht-benchmarks
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 3 Sep 2011 18:33:49 +0000 (14:33 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 3 Sep 2011 18:33:49 +0000 (14:33 -0400)
1  2 
rculfhash.c

diff --combined rculfhash.c
index cc8b22d68083f4f313efd6238acf81d74121135f,174c11cf7babb4a35a7d533b3dd557ab221ae3dc..0796f376e06ce63e3bd3ad4e3c33d7297d904b7e
  #include <stdio.h>
  #include <pthread.h>
  
 +#ifndef CDS_HT_NOATOMIC
 +# define test_cmpxchg(ptr, old, _new) uatomic_cmpxchg(ptr, old, _new)
 +#else
 +# define test_cmpxchg(ptr, old, _new)         \
 +({                                            \
 +      __typeof__(*(ptr)) __readptr = *(ptr);  \
 +      (__readptr == (old)) ? ({               \
 +              *(ptr) = (_new);                \
 +              (old);                          \
 +      }) : __readptr;                         \
 +})
 +#endif
 +
  #ifdef DEBUG
  #define dbg_printf(fmt, args...)     printf("[debug rculfhash] " fmt, ## args)
  #else
@@@ -418,7 -405,7 +418,7 @@@ unsigned long _uatomic_max(unsigned lon
                old2 = old1;
                if (old2 >= v)
                        return old2;
 -      } while ((old1 = uatomic_cmpxchg(ptr, old2, v)) != old2);
 +      } while ((old1 = test_cmpxchg(ptr, old2, v)) != old2);
        return v;
  }
  
@@@ -451,7 -438,7 +451,7 @@@ void _cds_lfht_gc_bucket(struct cds_lfh
                        new_next = flag_dummy(clear_flag(next));
                else
                        new_next = clear_flag(next);
 -              (void) uatomic_cmpxchg(&iter_prev->p.next, iter, new_next);
 +              (void) test_cmpxchg(&iter_prev->p.next, iter, new_next);
        }
  }
  
@@@ -517,7 -504,7 +517,7 @@@ struct cds_lfht_node *_cds_lfht_add(str
                        new_node = flag_dummy(node);
                else
                        new_node = node;
 -              if (uatomic_cmpxchg(&iter_prev->p.next, iter,
 +              if (test_cmpxchg(&iter_prev->p.next, iter,
                                    new_node) != iter)
                        continue;       /* retry */
                else
                        new_next = flag_dummy(clear_flag(next));
                else
                        new_next = clear_flag(next);
 -              (void) uatomic_cmpxchg(&iter_prev->p.next, iter, new_next);
 +              (void) test_cmpxchg(&iter_prev->p.next, iter, new_next);
                /* retry */
        }
  gc_end:
@@@ -557,7 -544,7 +557,7 @@@ int _cds_lfht_remove(struct cds_lfht *h
                if (unlikely(is_removed(next)))
                        goto end;
                assert(!is_dummy(next));
 -              old = uatomic_cmpxchg(&node->p.next, next,
 +              old = test_cmpxchg(&node->p.next, next,
                                      flag_removed(next));
        } while (old != next);
  
@@@ -635,7 -622,7 +635,7 @@@ struct cds_lfht *cds_lfht_new(cds_lfht_
        unsigned long order;
  
        /* init_size must be power of two */
-       if (init_size & (init_size - 1))
+       if (init_size && (init_size & (init_size - 1)))
                return NULL;
        ht = calloc(1, sizeof(struct cds_lfht));
        ht->hash_fct = hash_fct;
This page took 0.027444 seconds and 4 git commands to generate.