fix: handle EINTR correctly in get_cpu_mask_from_sysfs
[urcu.git] / tests / benchmark / test_urcu_hash.h
index b35acdb88330d41c8ff2f73307730c181443bc32..0ecb781a129b2804b74a5ae8253ae2d7bd030b97 100644 (file)
@@ -1,29 +1,14 @@
+// SPDX-FileCopyrightText: 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-or-later
+
 #ifndef _TEST_URCU_HASH_H
 #define _TEST_URCU_HASH_H
 
 /*
- * test_urcu_hash.h
- *
  * Userspace RCU library - test program
- *
- * Copyright 2009-2012 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "config.h"
 #include <stdio.h>
 #include <pthread.h>
 #include <stdlib.h>
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 #include <signal.h>
 
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
-#include <urcu/rand-compat.h>
-#include "cpuset.h"
+#include <compat-rand.h>
 #include "thread-id.h"
+#include "../common/debug-yield.h"
 
 #define DEFAULT_HASH_SIZE      32
 #define DEFAULT_MIN_ALLOC_SIZE 1
@@ -126,8 +111,6 @@ cds_lfht_iter_get_test_node(struct cds_lfht_iter *iter)
        return to_test_node(cds_lfht_iter_get_node(iter));
 }
 
-extern volatile int test_go, test_stop;
-
 extern unsigned long wdelay;
 
 extern unsigned long duration;
@@ -175,19 +158,6 @@ extern pthread_mutex_t affinity_mutex;
 
 void set_affinity(void);
 
-/*
- * returns 0 if test should end.
- */
-static inline int test_duration_write(void)
-{
-       return !test_stop;
-}
-
-static inline int test_duration_read(void)
-{
-       return !test_stop;
-}
-
 extern DECLARE_URCU_TLS(unsigned long long, nr_writes);
 extern DECLARE_URCU_TLS(unsigned long long, nr_reads);
 
@@ -249,10 +219,11 @@ uint32_t hash_u32(
 
        /*----------------------------------- handle the last 3 uint32_t's */
        switch (length) {       /* all the case statements fall through */
-       case 3: c += k[2];
-       case 2: b += k[1];
+       case 3: c += k[2]; /* fall through */
+       case 2: b += k[1]; /* fall through */
        case 1: a += k[0];
                final(a, b, c);
+               /* fall through */
        case 0:                 /* case 0: nothing left to add */
                break;
        }
@@ -285,10 +256,11 @@ void hashword2(
 
        /*----------------------------------- handle the last 3 uint32_t's */
        switch (length) {       /* all the case statements fall through */
-       case 3: c += k[2];
-       case 2: b += k[1];
+       case 3: c += k[2]; /* fall through */
+       case 2: b += k[1]; /* fall through */
        case 1: a += k[0];
                final(a, b, c);
+               /* fall through */
        case 0:                 /* case 0: nothing left to add */
                break;
        }
@@ -303,7 +275,7 @@ unsigned long test_hash_mix(const void *_key, size_t length, unsigned long seed)
 {
        unsigned int key = (unsigned int) _key;
 
-       assert(length == sizeof(unsigned int));
+       urcu_posix_assert(length == sizeof(unsigned int));
        return hash_u32(&key, 1, seed);
 }
 #else
@@ -319,7 +291,7 @@ unsigned long test_hash_mix(const void *_key, size_t length, unsigned long seed)
                uint32_t v32[2];
        } key;
 
-       assert(length == sizeof(unsigned long));
+       urcu_posix_assert(length == sizeof(unsigned long));
        v.v64 = (uint64_t) seed;
        key.v64 = (uint64_t) _key;
        hashword2(key.v32, 2, &v.v32[0], &v.v32[1]);
@@ -344,7 +316,7 @@ unsigned long test_hash(const void *_key, size_t length,
        } else {
                unsigned long v;
 
-               assert(length == sizeof(unsigned long));
+               urcu_posix_assert(length == sizeof(unsigned long));
                v = (unsigned long) _key;
                return v % nr_hash_chains;
        }
@@ -366,7 +338,7 @@ static inline
 void cds_lfht_test_lookup(struct cds_lfht *ht, void *key, size_t key_len,
                struct cds_lfht_iter *iter)
 {
-       assert(key_len == sizeof(unsigned long));
+       urcu_posix_assert(key_len == sizeof(unsigned long));
 
        cds_lfht_lookup(ht, test_hash(key, key_len, TEST_HASH_SEED),
                        test_match, key, iter);
This page took 0.026179 seconds and 4 git commands to generate.