X-Git-Url: http://git.lttng.org/?p=urcu.git;a=blobdiff_plain;f=src%2Frculfhash.c;fp=src%2Frculfhash.c;h=02c7f0f6dc3564fc4f10348a24ea89deee6a8a3d;hp=a453326a4124f11ac06aeb14697214d99b3c020d;hb=008a71ef213f23c8d403e086563155121b286c0c;hpb=1c64a40d8b2a4e65ae002ea0f15ab42f556b0987 diff --git a/src/rculfhash.c b/src/rculfhash.c index a453326..02c7f0f 100644 --- a/src/rculfhash.c +++ b/src/rculfhash.c @@ -347,6 +347,11 @@ struct partition_resize_work { unsigned long start, unsigned long len); }; +enum nr_cpus_mask_state { + NR_CPUS_MASK_INIT_FAILED = -2, + NR_CPUS_MASK_UNINITIALIZED = -1, +}; + static struct urcu_workqueue *cds_lfht_workqueue; /* @@ -624,7 +629,7 @@ static void mutex_unlock(pthread_mutex_t *mutex) urcu_die(ret); } -static long nr_cpus_mask = -1; +static long nr_cpus_mask = NR_CPUS_MASK_UNINITIALIZED; static long split_count_mask = -1; static int split_count_order = -1; @@ -634,7 +639,7 @@ static void ht_init_nr_cpus_mask(void) maxcpus = get_possible_cpus_array_len(); if (maxcpus <= 0) { - nr_cpus_mask = -2; + nr_cpus_mask = NR_CPUS_MASK_INIT_FAILED; return; } /* @@ -648,7 +653,7 @@ static void ht_init_nr_cpus_mask(void) static void alloc_split_items_count(struct cds_lfht *ht) { - if (nr_cpus_mask == -1) { + if (nr_cpus_mask == NR_CPUS_MASK_UNINITIALIZED) { ht_init_nr_cpus_mask(); if (nr_cpus_mask < 0) split_count_mask = DEFAULT_SPLIT_COUNT_MASK; @@ -1241,7 +1246,7 @@ void partition_resize_helper(struct cds_lfht *ht, unsigned long i, unsigned long thread, nr_threads; sigset_t newmask, oldmask; - urcu_posix_assert(nr_cpus_mask != -1); + urcu_posix_assert(nr_cpus_mask != NR_CPUS_MASK_UNINITIALIZED); if (nr_cpus_mask < 0 || len < 2 * MIN_PARTITION_PER_THREAD) goto fallback;