X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Frculfhash.c;h=5b62e05a8ba6f5134036300ef168353beeaab67a;hb=308c0e2f342b795203fd1b0f3346b85061a14d1f;hp=ff42df0aef30ecf567da51014cdd0a7c6235c96f;hpb=83e334d03eaba62df373cf44298616458900078a;p=urcu.git diff --git a/src/rculfhash.c b/src/rculfhash.c index ff42df0..5b62e05 100644 --- a/src/rculfhash.c +++ b/src/rculfhash.c @@ -273,13 +273,15 @@ #include #include #include -#include +#include #include #include #include +#include "rculfhash-internal.h" #include "workqueue.h" #include "urcu-die.h" #include "urcu-utils.h" +#include "compat-smp.h" /* * Split-counters lazily update the global counter each 1024 @@ -394,7 +396,8 @@ void cds_lfht_iter_debug_set_ht(struct cds_lfht *ht, struct cds_lfht_iter *iter) #else static -void cds_lfht_iter_debug_set_ht(struct cds_lfht *ht, struct cds_lfht_iter *iter) +void cds_lfht_iter_debug_set_ht(struct cds_lfht *ht __attribute__((unused)), + struct cds_lfht_iter *iter __attribute__((unused))) { } @@ -580,6 +583,7 @@ unsigned int cds_lfht_fls_ulong(unsigned long x) * Return the minimum order for which x <= (1UL << order). * Return -1 if x is 0. */ +static int cds_lfht_get_count_order_u32(uint32_t x) { if (!x) @@ -642,12 +646,11 @@ static long nr_cpus_mask = -1; static long split_count_mask = -1; static int split_count_order = -1; -#if defined(HAVE_SYSCONF) static void ht_init_nr_cpus_mask(void) { long maxcpus; - maxcpus = sysconf(_SC_NPROCESSORS_CONF); + maxcpus = get_possible_cpus_array_len(); if (maxcpus <= 0) { nr_cpus_mask = -2; return; @@ -659,12 +662,6 @@ static void ht_init_nr_cpus_mask(void) maxcpus = 1UL << cds_lfht_get_count_order_ulong(maxcpus); nr_cpus_mask = maxcpus - 1; } -#else /* #if defined(HAVE_SYSCONF) */ -static void ht_init_nr_cpus_mask(void) -{ - nr_cpus_mask = -2; -} -#endif /* #else #if defined(HAVE_SYSCONF) */ static void alloc_split_items_count(struct cds_lfht *ht) @@ -760,7 +757,7 @@ void ht_count_del(struct cds_lfht *ht, unsigned long size, unsigned long hash) if ((count >> CHAIN_LEN_RESIZE_THRESHOLD) >= size) return; - dbg_printf("del set global %ld\n", count); + dbg_printf("del set global %lu\n", count); /* * Don't shrink table if the number of nodes is below a * certain threshold. @@ -825,7 +822,7 @@ struct cds_lfht_node *clear_flag(struct cds_lfht_node *node) } static -int is_removed(struct cds_lfht_node *node) +int is_removed(const struct cds_lfht_node *node) { return ((unsigned long) node) & REMOVED_FLAG; } @@ -1568,7 +1565,8 @@ const struct cds_lfht_mm_type *get_mm_type(unsigned long max_nr_buckets) * For 32-bit architectures, use the order allocator. */ static -const struct cds_lfht_mm_type *get_mm_type(unsigned long max_nr_buckets) +const struct cds_lfht_mm_type *get_mm_type( + unsigned long max_nr_buckets __attribute__((unused))) { return &cds_lfht_mm_order; } @@ -1673,7 +1671,8 @@ void cds_lfht_lookup(struct cds_lfht *ht, unsigned long hash, iter->next = next; } -void cds_lfht_next_duplicate(struct cds_lfht *ht, cds_lfht_match_fct match, +void cds_lfht_next_duplicate(struct cds_lfht *ht __attribute__((unused)), + cds_lfht_match_fct match, const void *key, struct cds_lfht_iter *iter) { struct cds_lfht_node *node, *next; @@ -1707,7 +1706,8 @@ void cds_lfht_next_duplicate(struct cds_lfht *ht, cds_lfht_match_fct match, iter->next = next; } -void cds_lfht_next(struct cds_lfht *ht, struct cds_lfht_iter *iter) +void cds_lfht_next(struct cds_lfht *ht __attribute__((unused)), + struct cds_lfht_iter *iter) { struct cds_lfht_node *node, *next; @@ -1829,7 +1829,7 @@ int cds_lfht_del(struct cds_lfht *ht, struct cds_lfht_node *node) return ret; } -int cds_lfht_is_node_deleted(struct cds_lfht_node *node) +int cds_lfht_is_node_deleted(const struct cds_lfht_node *node) { return is_removed(CMM_LOAD_SHARED(node->next)); } @@ -2113,7 +2113,7 @@ void cds_lfht_resize_lazy_count(struct cds_lfht *ht, unsigned long size, __cds_lfht_resize_lazy_launch(ht); } -static void cds_lfht_before_fork(void *priv) +static void cds_lfht_before_fork(void *priv __attribute__((unused))) { if (cds_lfht_workqueue_atfork_nesting++) return; @@ -2123,7 +2123,7 @@ static void cds_lfht_before_fork(void *priv) urcu_workqueue_pause_worker(cds_lfht_workqueue); } -static void cds_lfht_after_fork_parent(void *priv) +static void cds_lfht_after_fork_parent(void *priv __attribute__((unused))) { if (--cds_lfht_workqueue_atfork_nesting) return; @@ -2134,7 +2134,7 @@ end: mutex_unlock(&cds_lfht_fork_mutex); } -static void cds_lfht_after_fork_child(void *priv) +static void cds_lfht_after_fork_child(void *priv __attribute__((unused))) { if (--cds_lfht_workqueue_atfork_nesting) return; @@ -2151,18 +2151,25 @@ static struct urcu_atfork cds_lfht_atfork = { .after_fork_child = cds_lfht_after_fork_child, }; -/* Block all signals to ensure we don't disturb the application. */ -static void cds_lfht_worker_init(struct urcu_workqueue *workqueue, - void *priv) +/* + * Block all signals for the workqueue worker thread to ensure we don't + * disturb the application. The SIGRCU signal needs to be unblocked for + * the urcu-signal flavor. + */ +static void cds_lfht_worker_init( + struct urcu_workqueue *workqueue __attribute__((unused)), + void *priv __attribute__((unused))) { int ret; sigset_t mask; - /* Block signal for entire process, so only our thread processes it. */ ret = sigfillset(&mask); if (ret) urcu_die(errno); - ret = pthread_sigmask(SIG_BLOCK, &mask, NULL); + ret = sigdelset(&mask, SIGRCU); + if (ret) + urcu_die(errno); + ret = pthread_sigmask(SIG_SETMASK, &mask, NULL); if (ret) urcu_die(ret); }