Add `urcu_posix_assert()` as `assert()` replacement
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 1 Sep 2021 17:34:17 +0000 (13:34 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 3 Sep 2021 18:31:37 +0000 (14:31 -0400)
This macro acts like the regular `assert()` macro unless NDEBUG is
defined in which case it consumes the expression and becomes a no-op.

This consumption trick (see `_urcu_use_expression()` macro) prevents the
compiler from warning about unused variables even when assert() are
removed by the NDEBUG define.

This macro is also used for the existing `urcu_assert_debug()` macro.

The implementation of `_urcu_use_expression()` is inspired by the
Babeltrace 2 approach.

See `BT_USE_EXPR()` macro and documentation in Babeltrace commit [1]:
  commit 1778c2a4134647150b199b2b57130817144446b0
  Author: Philippe Proulx <eeppeliteloop@gmail.com>
  Date:   Tue Apr 21 11:15:42 2020 -0400
  lib: assign a unique ID to each pre/postcond. and report it on failure

All assertion macros are moved to the new urcu/assert.h file.

Link: https://github.com/efficios/babeltrace/commit/1778c2a4134647150b199b2b57130817144446b0
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If60ce2d3f45ea8f5ec1dbb92fb43f83fd9f8102b

57 files changed:
include/Makefile.am
include/urcu/assert.h [new file with mode: 0644]
include/urcu/debug.h
include/urcu/rculfqueue.h
include/urcu/ref.h
include/urcu/static/lfstack.h
include/urcu/static/rculfqueue.h
include/urcu/static/urcu-bp.h
include/urcu/static/urcu-common.h
include/urcu/static/urcu-mb.h
include/urcu/static/urcu-memb.h
include/urcu/static/urcu-qsbr.h
include/urcu/static/urcu-signal.h
include/urcu/static/wfcqueue.h
include/urcu/static/wfqueue.h
include/urcu/static/wfstack.h
include/urcu/wfcqueue.h
include/urcu/wfqueue.h
include/urcu/wfstack.h
src/compat_arch.c
src/compat_futex.c
src/rculfhash-internal.h
src/rculfhash-mm-chunk.c
src/rculfhash-mm-mmap.c
src/rculfhash-mm-order.c
src/rculfhash.c
src/urcu-bp.c
src/urcu-call-rcu-impl.h
src/urcu-defer-impl.h
src/urcu-qsbr.c
src/urcu-wait.h
src/urcu.c
src/workqueue.c
tests/benchmark/test_looplen.c
tests/benchmark/test_mutex.c
tests/benchmark/test_perthreadlock.c
tests/benchmark/test_perthreadlock_timing.c
tests/benchmark/test_rwlock.c
tests/benchmark/test_rwlock_timing.c
tests/benchmark/test_urcu.c
tests/benchmark/test_urcu_assign.c
tests/benchmark/test_urcu_bp.c
tests/benchmark/test_urcu_defer.c
tests/benchmark/test_urcu_gc.c
tests/benchmark/test_urcu_hash.c
tests/benchmark/test_urcu_hash.h
tests/benchmark/test_urcu_lfq.c
tests/benchmark/test_urcu_lfs.c
tests/benchmark/test_urcu_lfs_rcu.c
tests/benchmark/test_urcu_qsbr.c
tests/benchmark/test_urcu_qsbr_gc.c
tests/benchmark/test_urcu_qsbr_timing.c
tests/benchmark/test_urcu_timing.c
tests/benchmark/test_urcu_wfcq.c
tests/benchmark/test_urcu_wfq.c
tests/benchmark/test_urcu_wfs.c
tests/regression/test_urcu_fork.c

index 3f92cc3668471c8d8e2f3d47fdad753526ff4712..b55bcf0271290e6e440c5b66ce87089dd5903063 100644 (file)
@@ -16,6 +16,7 @@ nobase_include_HEADERS = \
        urcu/arch/sparc64.h \
        urcu/arch/tile.h \
        urcu/arch/x86.h \
+       urcu/assert.h \
        urcu/call-rcu.h \
        urcu/cds.h \
        urcu/compiler.h \
diff --git a/include/urcu/assert.h b/include/urcu/assert.h
new file mode 100644 (file)
index 0000000..c22419f
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef _URCU_ASSERT_H
+#define _URCU_ASSERT_H
+
+/*
+ * urcu/assert.h
+ *
+ * Userspace RCU assertion facilities.
+ *
+ * Copyright (c) 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#include <urcu/config.h>
+
+/*
+ * Force usage of an expression to prevent unused expression compiler warning.
+ */
+#define _urcu_use_expression(_expr) ((void) sizeof((void) (_expr), 0))
+
+#ifdef NDEBUG
+/*
+ * Vanilla assert() replacement. When NDEBUG is defined, the expression is
+ * consumed to prevent unused variable compile warnings.
+ */
+# define urcu_posix_assert(_cond) _urcu_use_expression(_cond)
+#else
+# include <assert.h>
+# define urcu_posix_assert(_cond) assert(_cond)
+#endif
+
+#if defined(DEBUG_RCU) || defined(CONFIG_RCU_DEBUG)
+
+/*
+ * Enables debugging/expensive assertions to be used in fast paths and only
+ * enabled on demand. When disabled, the expression is consumed to prevent
+ * unused variable compile warnings.
+ */
+# define urcu_assert_debug(_cond) urcu_posix_assert(_cond)
+#else
+# define urcu_assert_debug(_cond) _urcu_use_expression(_cond)
+#endif
+
+#endif /* _URCU_ASSERT_H */
index 1920a7dd4f0a61c69ecd416c767d8ef9db73bb1d..41727f378e4368be2cd11c20f682bb3d4588618b 100644 (file)
  * all copies or substantial portions of the Software.
  */
 
-#include <assert.h>
-
-#include <urcu/config.h>
-
-#if defined(DEBUG_RCU) || defined(CONFIG_RCU_DEBUG)
-# define urcu_assert_debug(...) assert(__VA_ARGS__)
-#else
-# define urcu_assert_debug(...)
-#endif
+#include <urcu/assert.h>
 
 /*
  * For backward compatibility reasons, this file must expose the urcu_assert()
index 7e8078952c75302b8af10c10f421e1294bd3e34d..2c06247b5b958246fec2680911af088a37a20de2 100644 (file)
@@ -23,7 +23,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <assert.h>
 
 #ifdef __cplusplus
 extern "C" {
index e546da567120e086e5773950ac135d510900b4fc..e7ab5310aa5d4a2a4deff4f988cdc4bf5063d56c 100644 (file)
  * published by the Free  Software Foundation.
  */
 
-#include <assert.h>
 #include <stdbool.h>
 #include <limits.h>
 #include <stdlib.h>
+#include <urcu/assert.h>
 #include <urcu/uatomic.h>
 
 struct urcu_ref {
@@ -63,7 +63,7 @@ static inline void urcu_ref_put(struct urcu_ref *ref,
                                void (*release)(struct urcu_ref *))
 {
        long res = uatomic_sub_return(&ref->refcount, 1);
-       assert (res >= 0);
+       urcu_posix_assert(res >= 0);
        if (res == 0)
                release(ref);
 }
index b8b544feeed551121aeaf1ade5970e5eac9d0f8b..6c82b42c0ef9922b2c3c5ee9cdc1cca3feb69b14 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <stdbool.h>
 #include <pthread.h>
-#include <assert.h>
+#include <urcu/assert.h>
 #include <urcu/uatomic.h>
 #include <urcu-pointer.h>
 
@@ -76,7 +76,7 @@ void _cds_lfs_init(struct cds_lfs_stack *s)
 
        s->head = NULL;
        ret = pthread_mutex_init(&s->lock, NULL);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 /*
@@ -87,7 +87,7 @@ static inline
 void _cds_lfs_destroy(struct cds_lfs_stack *s)
 {
         int ret = pthread_mutex_destroy(&s->lock);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 /*
@@ -267,7 +267,7 @@ static inline void _cds_lfs_pop_lock(struct cds_lfs_stack *s)
        int ret;
 
        ret = pthread_mutex_lock(&s->lock);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 /*
@@ -278,7 +278,7 @@ static inline void _cds_lfs_pop_unlock(struct cds_lfs_stack *s)
        int ret;
 
        ret = pthread_mutex_unlock(&s->lock);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 /*
index af73c6f2ef7565dc69e16f62d539ded7ed66d583..a8e109138e10d4e06945e941328454aed8627f43 100644 (file)
@@ -27,9 +27,9 @@
  */
 
 #include <urcu-call-rcu.h>
+#include <urcu/assert.h>
 #include <urcu/uatomic.h>
 #include <urcu-pointer.h>
-#include <assert.h>
 #include <errno.h>
 
 #ifdef __cplusplus
@@ -67,7 +67,7 @@ struct cds_lfq_node_rcu *make_dummy(struct cds_lfq_queue_rcu *q,
        struct cds_lfq_node_rcu_dummy *dummy;
 
        dummy = malloc(sizeof(struct cds_lfq_node_rcu_dummy));
-       assert(dummy);
+       urcu_posix_assert(dummy);
        dummy->parent.next = next;
        dummy->parent.dummy = 1;
        dummy->q = q;
@@ -87,7 +87,7 @@ void rcu_free_dummy(struct cds_lfq_node_rcu *node)
 {
        struct cds_lfq_node_rcu_dummy *dummy;
 
-       assert(node->dummy);
+       urcu_posix_assert(node->dummy);
        dummy = caa_container_of(node, struct cds_lfq_node_rcu_dummy, parent);
        dummy->q->queue_call_rcu(&dummy->head, free_dummy_cb);
 }
@@ -97,7 +97,7 @@ void free_dummy(struct cds_lfq_node_rcu *node)
 {
        struct cds_lfq_node_rcu_dummy *dummy;
 
-       assert(node->dummy);
+       urcu_posix_assert(node->dummy);
        dummy = caa_container_of(node, struct cds_lfq_node_rcu_dummy, parent);
        free(dummy);
 }
index 7f5d8736f4cd3b9c03cfb1617646bd9b1eb07df6..8ba3830b243d7e05bfddb84081a2db46f3a00beb 100644 (file)
@@ -33,6 +33,7 @@
 #include <pthread.h>
 #include <unistd.h>
 
+#include <urcu/debug.h>
 #include <urcu/config.h>
 #include <urcu/compiler.h>
 #include <urcu/arch.h>
@@ -40,7 +41,6 @@
 #include <urcu/uatomic.h>
 #include <urcu/list.h>
 #include <urcu/tls-compat.h>
-#include <urcu/debug.h>
 
 /*
  * This code section can only be included in LGPL 2.1 compatible source code.
index 28d3160cb2cce1ff18e5e9c662e6644be41e12c9..60ea8b858b0feed7c3015c0a8fc12878e795e93f 100644 (file)
@@ -42,7 +42,6 @@
 #include <urcu/list.h>
 #include <urcu/futex.h>
 #include <urcu/tls-compat.h>
-#include <urcu/debug.h>
 
 #ifdef __cplusplus
 extern "C" {
index 20e604da64a1da6096b664f6791d2c8932ec7612..b97e42a6b5afc623a99149047a1f81e2301fa364 100644 (file)
@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include <stdint.h>
 
+#include <urcu/debug.h>
 #include <urcu/config.h>
 #include <urcu/compiler.h>
 #include <urcu/arch.h>
@@ -42,7 +43,6 @@
 #include <urcu/list.h>
 #include <urcu/futex.h>
 #include <urcu/tls-compat.h>
-#include <urcu/debug.h>
 #include <urcu/static/urcu-common.h>
 
 #ifdef __cplusplus
index 65a985b355bc23a4ead607bdca0088bb007f15db..c8d102f1c2653e5390890d1decc124c86d53230b 100644 (file)
@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include <stdint.h>
 
+#include <urcu/debug.h>
 #include <urcu/config.h>
 #include <urcu/compiler.h>
 #include <urcu/arch.h>
@@ -42,7 +43,6 @@
 #include <urcu/list.h>
 #include <urcu/futex.h>
 #include <urcu/tls-compat.h>
-#include <urcu/debug.h>
 #include <urcu/static/urcu-common.h>
 
 #ifdef __cplusplus
index 5eca3e24cf6b600c27f6d01c685cd5e6bbfc0392..b8788771c33103f44981cac1ad381fe525dcf3ce 100644 (file)
@@ -35,6 +35,7 @@
 #include <unistd.h>
 #include <stdint.h>
 
+#include <urcu/debug.h>
 #include <urcu/compiler.h>
 #include <urcu/arch.h>
 #include <urcu/system.h>
@@ -42,7 +43,6 @@
 #include <urcu/list.h>
 #include <urcu/futex.h>
 #include <urcu/tls-compat.h>
-#include <urcu/debug.h>
 #include <urcu/static/urcu-common.h>
 
 #ifdef __cplusplus
index 56730e17d449494f81ba41d4f00e86a0178f21f6..c7577d3b82149921eda468e6799223847f1cd692 100644 (file)
@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include <stdint.h>
 
+#include <urcu/debug.h>
 #include <urcu/config.h>
 #include <urcu/compiler.h>
 #include <urcu/arch.h>
@@ -42,7 +43,6 @@
 #include <urcu/list.h>
 #include <urcu/futex.h>
 #include <urcu/tls-compat.h>
-#include <urcu/debug.h>
 #include <urcu/static/urcu-common.h>
 #include <urcu/static/urcu-signal-nr.h>
 
index 5e54cbed3526a7617428f88f9f3e33bbb379fca8..478e8598a6b2898694d9d1d4856691390ffbce66 100644 (file)
@@ -28,9 +28,9 @@
  */
 
 #include <pthread.h>
-#include <assert.h>
 #include <poll.h>
 #include <stdbool.h>
+#include <urcu/assert.h>
 #include <urcu/compiler.h>
 #include <urcu/uatomic.h>
 
@@ -104,7 +104,7 @@ static inline void _cds_wfcq_init(struct cds_wfcq_head *head,
        _cds_wfcq_node_init(&head->node);
        tail->p = &head->node;
        ret = pthread_mutex_init(&head->lock, NULL);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 /*
@@ -115,7 +115,7 @@ static inline void _cds_wfcq_destroy(struct cds_wfcq_head *head,
                struct cds_wfcq_tail *tail __attribute__((unused)))
 {
        int ret = pthread_mutex_destroy(&head->lock);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 /*
@@ -163,7 +163,7 @@ static inline void _cds_wfcq_dequeue_lock(struct cds_wfcq_head *head,
        int ret;
 
        ret = pthread_mutex_lock(&head->lock);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 static inline void _cds_wfcq_dequeue_unlock(struct cds_wfcq_head *head,
@@ -172,7 +172,7 @@ static inline void _cds_wfcq_dequeue_unlock(struct cds_wfcq_head *head,
        int ret;
 
        ret = pthread_mutex_unlock(&head->lock);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 static inline bool ___cds_wfcq_append(cds_wfcq_head_ptr_t u_head,
index df9f62f28bafa189a5b2f0d61fcbfce8b978b7b4..d04f66f35c895d4184e5056d7172ce8d865f69e3 100644 (file)
@@ -27,8 +27,8 @@
  */
 
 #include <pthread.h>
-#include <assert.h>
 #include <poll.h>
+#include <urcu/assert.h>
 #include <urcu/compiler.h>
 #include <urcu/uatomic.h>
 
@@ -62,13 +62,13 @@ static inline void _cds_wfq_init(struct cds_wfq_queue *q)
        q->head = &q->dummy;
        q->tail = &q->dummy.next;
        ret = pthread_mutex_init(&q->lock, NULL);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 static inline void _cds_wfq_destroy(struct cds_wfq_queue *q)
 {
        int ret = pthread_mutex_destroy(&q->lock);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 static inline void _cds_wfq_enqueue(struct cds_wfq_queue *q,
@@ -157,10 +157,10 @@ _cds_wfq_dequeue_blocking(struct cds_wfq_queue *q)
        int ret;
 
        ret = pthread_mutex_lock(&q->lock);
-       assert(!ret);
+       urcu_posix_assert(!ret);
        retnode = ___cds_wfq_dequeue_blocking(q);
        ret = pthread_mutex_unlock(&q->lock);
-       assert(!ret);
+       urcu_posix_assert(!ret);
        return retnode;
 }
 
index e96c8876a2b916dcd5bde1e1ba2ad3f8b5ff4ec8..bd7ba688e31c4964d854c9f612b4b0f70377081b 100644 (file)
@@ -27,9 +27,9 @@
  */
 
 #include <pthread.h>
-#include <assert.h>
 #include <poll.h>
 #include <stdbool.h>
+#include <urcu/assert.h>
 #include <urcu/compiler.h>
 #include <urcu/uatomic.h>
 
@@ -96,7 +96,7 @@ void _cds_wfs_init(struct cds_wfs_stack *s)
 
        s->head = CDS_WFS_END;
        ret = pthread_mutex_init(&s->lock, NULL);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 /*
@@ -107,7 +107,7 @@ static inline
 void _cds_wfs_destroy(struct cds_wfs_stack *s)
 {
        int ret = pthread_mutex_destroy(&s->lock);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 static inline bool ___cds_wfs_end(void *node)
@@ -142,7 +142,7 @@ int _cds_wfs_push(cds_wfs_stack_ptr_t u_stack, struct cds_wfs_node *node)
        struct __cds_wfs_stack *s = u_stack._s;
        struct cds_wfs_head *old_head, *new_head;
 
-       assert(node->next == NULL);
+       urcu_posix_assert(node->next == NULL);
        new_head = caa_container_of(node, struct cds_wfs_head, node);
        /*
         * uatomic_xchg() implicit memory barrier orders earlier stores
@@ -323,7 +323,7 @@ static inline void _cds_wfs_pop_lock(struct cds_wfs_stack *s)
        int ret;
 
        ret = pthread_mutex_lock(&s->lock);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 /*
@@ -334,7 +334,7 @@ static inline void _cds_wfs_pop_unlock(struct cds_wfs_stack *s)
        int ret;
 
        ret = pthread_mutex_unlock(&s->lock);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 /*
index 6c6ebba9e4453257da70484cecc6840bbdab0364..407c0dbdbb39118473789b3f4a446ef02062db29 100644 (file)
@@ -25,7 +25,6 @@
  */
 
 #include <pthread.h>
-#include <assert.h>
 #include <stdbool.h>
 #include <urcu/compiler.h>
 #include <urcu/arch.h>
index 2ba86248aa7095c4ca83e94b13769c073507a58c..214d3bf2f6d06b1774485bf3fe589d952c32eec8 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include <pthread.h>
-#include <assert.h>
 #include <urcu/compiler.h>
 
 #ifdef __cplusplus
index 9d693053117ceb93e69034e433f2196a22c3070d..1058fba9baa4dc0fa89b1250e68f5c2814e486e2 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include <pthread.h>
-#include <assert.h>
 #include <stdbool.h>
 #include <urcu/compiler.h>
 
index 73f7d2d2f441e2e1fe4ef8771c807f2ebd0b7606..e1651d3db9a2110ae18702c85dc4b7f1cb574838 100644 (file)
@@ -27,7 +27,7 @@
 #include <stdio.h>
 #include <pthread.h>
 #include <signal.h>
-#include <assert.h>
+#include <urcu/assert.h>
 #include <urcu/uatomic.h>
 
 /*
@@ -95,11 +95,11 @@ static void mutex_lock_signal_save(pthread_mutex_t *mutex, sigset_t *oldmask)
 
        /* Disable signals */
        ret = sigfillset(&newmask);
-       assert(!ret);
+       urcu_posix_assert(!ret);
        ret = pthread_sigmask(SIG_BLOCK, &newmask, oldmask);
-       assert(!ret);
+       urcu_posix_assert(!ret);
        ret = pthread_mutex_lock(&__urcu_x86_compat_mutex);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 static void mutex_lock_signal_restore(pthread_mutex_t *mutex, sigset_t *oldmask)
@@ -107,9 +107,9 @@ static void mutex_lock_signal_restore(pthread_mutex_t *mutex, sigset_t *oldmask)
        int ret;
 
        ret = pthread_mutex_unlock(&__urcu_x86_compat_mutex);
-       assert(!ret);
+       urcu_posix_assert(!ret);
        ret = pthread_sigmask(SIG_SETMASK, oldmask, NULL);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 unsigned long _compat_uatomic_set(void *addr, unsigned long _new, int len)
index 9e918fe8e2aac035dc39e6e23868410348d02627..9281138723da6a1ddefd67f91e37211ea10a53fd 100644 (file)
 #include <stdio.h>
 #include <pthread.h>
 #include <signal.h>
-#include <assert.h>
 #include <errno.h>
 #include <poll.h>
 #include <stdint.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/futex.h>
 #include <urcu/system.h>
 
@@ -60,9 +60,9 @@ int compat_futex_noasync(int32_t *uaddr, int op, int32_t val,
         * Check if NULL. Don't let users expect that they are taken into
         * account.
         */
-       assert(!timeout);
-       assert(!uaddr2);
-       assert(!val3);
+       urcu_posix_assert(!timeout);
+       urcu_posix_assert(!uaddr2);
+       urcu_posix_assert(!val3);
 
        /*
         * memory barriers to serialize with the previous uaddr modification.
@@ -124,9 +124,9 @@ int compat_futex_async(int32_t *uaddr, int op, int32_t val,
         * Check if NULL. Don't let users expect that they are taken into
         * account.
         */
-       assert(!timeout);
-       assert(!uaddr2);
-       assert(!val3);
+       urcu_posix_assert(!timeout);
+       urcu_posix_assert(!uaddr2);
+       urcu_posix_assert(!val3);
 
        /*
         * Ensure previous memory operations on uaddr have completed.
index d29a9232c03e6c42c844d8bfaaf3f63e588c5473..e17210b8624cf7fd370ef88f591174e100085548 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <urcu/assert.h>
 #include <urcu/rculfhash.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <assert.h>
 
 #ifdef DEBUG
 #define dbg_printf(fmt, args...)     printf("[debug rculfhash] " fmt, ## args)
@@ -170,7 +170,7 @@ struct cds_lfht *__default_alloc_cds_lfht(
        struct cds_lfht *ht;
 
        ht = calloc(1, cds_lfht_size);
-       assert(ht);
+       urcu_posix_assert(ht);
 
        ht->mm = mm;
        ht->bucket_at = mm->bucket_at;
index a7a9b765b4c2c734389b869fc8c4f0ceb7e46281..9273ac9755c295cf29d5006698827da821ad2ef3 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <stddef.h>
+#include <urcu/assert.h>
 #include <rculfhash-internal.h>
 
 static
@@ -29,14 +30,14 @@ void cds_lfht_alloc_bucket_table(struct cds_lfht *ht, unsigned long order)
        if (order == 0) {
                ht->tbl_chunk[0] = calloc(ht->min_nr_alloc_buckets,
                        sizeof(struct cds_lfht_node));
-               assert(ht->tbl_chunk[0]);
+               urcu_posix_assert(ht->tbl_chunk[0]);
        } else if (order > ht->min_alloc_buckets_order) {
                unsigned long i, len = 1UL << (order - 1 - ht->min_alloc_buckets_order);
 
                for (i = len; i < 2 * len; i++) {
                        ht->tbl_chunk[i] = calloc(ht->min_nr_alloc_buckets,
                                sizeof(struct cds_lfht_node));
-                       assert(ht->tbl_chunk[i]);
+                       urcu_posix_assert(ht->tbl_chunk[i]);
                }
        }
        /* Nothing to do for 0 < order && order <= ht->min_alloc_buckets_order */
index 72333a866da098a7107cde22a666ac6c36b84d41..4bce972094881bf3d8dc031be87241cd933b18c4 100644 (file)
@@ -25,6 +25,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <sys/mman.h>
+#include <urcu/assert.h>
 #include "rculfhash-internal.h"
 
 #ifndef MAP_ANONYMOUS
@@ -133,7 +134,7 @@ void cds_lfht_alloc_bucket_table(struct cds_lfht *ht, unsigned long order)
                        /* small table */
                        ht->tbl_mmap = calloc(ht->max_nr_buckets,
                                        sizeof(*ht->tbl_mmap));
-                       assert(ht->tbl_mmap);
+                       urcu_posix_assert(ht->tbl_mmap);
                        return;
                }
                /* large table */
@@ -145,7 +146,7 @@ void cds_lfht_alloc_bucket_table(struct cds_lfht *ht, unsigned long order)
                /* large table */
                unsigned long len = 1UL << (order - 1);
 
-               assert(ht->min_nr_alloc_buckets < ht->max_nr_buckets);
+               urcu_posix_assert(ht->min_nr_alloc_buckets < ht->max_nr_buckets);
                memory_populate(ht->tbl_mmap + len,
                                len * sizeof(*ht->tbl_mmap));
        }
@@ -173,7 +174,7 @@ void cds_lfht_free_bucket_table(struct cds_lfht *ht, unsigned long order)
                /* large table */
                unsigned long len = 1UL << (order - 1);
 
-               assert(ht->min_nr_alloc_buckets < ht->max_nr_buckets);
+               urcu_posix_assert(ht->min_nr_alloc_buckets < ht->max_nr_buckets);
                memory_discard(ht->tbl_mmap + len, len * sizeof(*ht->tbl_mmap));
        }
        /* Nothing to do for 0 < order && order <= ht->min_alloc_buckets_order */
index 20f3edd8ce37cf9a5abe88e18264ec1102759b53..a182a838867b9388a193845c856539bdf892955a 100644 (file)
@@ -21,6 +21,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <urcu/assert.h>
 #include <rculfhash-internal.h>
 
 static
@@ -29,11 +30,11 @@ void cds_lfht_alloc_bucket_table(struct cds_lfht *ht, unsigned long order)
        if (order == 0) {
                ht->tbl_order[0] = calloc(ht->min_nr_alloc_buckets,
                        sizeof(struct cds_lfht_node));
-               assert(ht->tbl_order[0]);
+               urcu_posix_assert(ht->tbl_order[0]);
        } else if (order > ht->min_alloc_buckets_order) {
                ht->tbl_order[order] = calloc(1UL << (order -1),
                        sizeof(struct cds_lfht_node));
-               assert(ht->tbl_order[order]);
+               urcu_posix_assert(ht->tbl_order[order]);
        }
        /* Nothing to do for 0 < order && order <= ht->min_alloc_buckets_order */
 }
index 9106a745ff29a24dcefef9a1e671ee28fd68b7e1..04fd49946aa940184015a4921971feff5d3818e5 100644 (file)
 #define _LGPL_SOURCE
 #include <stdlib.h>
 #include <errno.h>
-#include <assert.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <string.h>
 #include <unistd.h>
 
 #include "compat-getcpu.h"
+#include <urcu/assert.h>
 #include <urcu/pointer.h>
 #include <urcu/call-rcu.h>
 #include <urcu/flavor.h>
@@ -390,7 +390,7 @@ void cds_lfht_iter_debug_set_ht(struct cds_lfht *ht, struct cds_lfht_iter *iter)
        iter->lfht = ht;
 }
 
-#define cds_lfht_iter_debug_assert(...)                assert(__VA_ARGS__)
+#define cds_lfht_iter_debug_assert(...)                urcu_posix_assert(__VA_ARGS__)
 
 #else
 
@@ -682,12 +682,12 @@ void alloc_split_items_count(struct cds_lfht *ht)
                        cds_lfht_get_count_order_ulong(split_count_mask + 1);
        }
 
-       assert(split_count_mask >= 0);
+       urcu_posix_assert(split_count_mask >= 0);
 
        if (ht->flags & CDS_LFHT_ACCOUNTING) {
                ht->split_count = calloc(split_count_mask + 1,
                                        sizeof(struct ht_items_count));
-               assert(ht->split_count);
+               urcu_posix_assert(ht->split_count);
        } else {
                ht->split_count = NULL;
        }
@@ -704,7 +704,7 @@ int ht_get_split_count_index(unsigned long hash)
 {
        int cpu;
 
-       assert(split_count_mask >= 0);
+       urcu_posix_assert(split_count_mask >= 0);
        cpu = urcu_sched_getcpu();
        if (caa_unlikely(cpu < 0))
                return hash & split_count_mask;
@@ -917,7 +917,7 @@ static inline
 struct cds_lfht_node *lookup_bucket(struct cds_lfht *ht, unsigned long size,
                unsigned long hash)
 {
-       assert(size > 0);
+       urcu_posix_assert(size > 0);
        return bucket_at(ht, hash & (size - 1));
 }
 
@@ -929,26 +929,26 @@ void _cds_lfht_gc_bucket(struct cds_lfht_node *bucket, struct cds_lfht_node *nod
 {
        struct cds_lfht_node *iter_prev, *iter, *next, *new_next;
 
-       assert(!is_bucket(bucket));
-       assert(!is_removed(bucket));
-       assert(!is_removal_owner(bucket));
-       assert(!is_bucket(node));
-       assert(!is_removed(node));
-       assert(!is_removal_owner(node));
+       urcu_posix_assert(!is_bucket(bucket));
+       urcu_posix_assert(!is_removed(bucket));
+       urcu_posix_assert(!is_removal_owner(bucket));
+       urcu_posix_assert(!is_bucket(node));
+       urcu_posix_assert(!is_removed(node));
+       urcu_posix_assert(!is_removal_owner(node));
        for (;;) {
                iter_prev = bucket;
                /* We can always skip the bucket node initially */
                iter = rcu_dereference(iter_prev->next);
-               assert(!is_removed(iter));
-               assert(!is_removal_owner(iter));
-               assert(iter_prev->reverse_hash <= node->reverse_hash);
+               urcu_posix_assert(!is_removed(iter));
+               urcu_posix_assert(!is_removal_owner(iter));
+               urcu_posix_assert(iter_prev->reverse_hash <= node->reverse_hash);
                /*
                 * We should never be called with bucket (start of chain)
                 * and logically removed node (end of path compression
                 * marker) being the actual same node. This would be a
                 * bug in the algorithm implementation.
                 */
-               assert(bucket != node);
+               urcu_posix_assert(bucket != node);
                for (;;) {
                        if (caa_unlikely(is_end(iter)))
                                return;
@@ -960,8 +960,8 @@ void _cds_lfht_gc_bucket(struct cds_lfht_node *bucket, struct cds_lfht_node *nod
                        iter_prev = clear_flag(iter);
                        iter = next;
                }
-               assert(!is_removed(iter));
-               assert(!is_removal_owner(iter));
+               urcu_posix_assert(!is_removed(iter));
+               urcu_posix_assert(!is_removal_owner(iter));
                if (is_bucket(iter))
                        new_next = flag_bucket(clear_flag(next));
                else
@@ -981,13 +981,13 @@ int _cds_lfht_replace(struct cds_lfht *ht, unsigned long size,
        if (!old_node)  /* Return -ENOENT if asked to replace NULL node */
                return -ENOENT;
 
-       assert(!is_removed(old_node));
-       assert(!is_removal_owner(old_node));
-       assert(!is_bucket(old_node));
-       assert(!is_removed(new_node));
-       assert(!is_removal_owner(new_node));
-       assert(!is_bucket(new_node));
-       assert(new_node != old_node);
+       urcu_posix_assert(!is_removed(old_node));
+       urcu_posix_assert(!is_removal_owner(old_node));
+       urcu_posix_assert(!is_bucket(old_node));
+       urcu_posix_assert(!is_removed(new_node));
+       urcu_posix_assert(!is_removal_owner(new_node));
+       urcu_posix_assert(!is_bucket(new_node));
+       urcu_posix_assert(new_node != old_node);
        for (;;) {
                /* Insert after node to be replaced */
                if (is_removed(old_next)) {
@@ -997,14 +997,14 @@ int _cds_lfht_replace(struct cds_lfht *ht, unsigned long size,
                         */
                        return -ENOENT;
                }
-               assert(old_next == clear_flag(old_next));
-               assert(new_node != old_next);
+               urcu_posix_assert(old_next == clear_flag(old_next));
+               urcu_posix_assert(new_node != old_next);
                /*
                 * REMOVAL_OWNER flag is _NEVER_ set before the REMOVED
                 * flag. It is either set atomically at the same time
                 * (replace) or after (del).
                 */
-               assert(!is_removal_owner(old_next));
+               urcu_posix_assert(!is_removal_owner(old_next));
                new_node->next = old_next;
                /*
                 * Here is the whole trick for lock-free replace: we add
@@ -1036,7 +1036,7 @@ int _cds_lfht_replace(struct cds_lfht *ht, unsigned long size,
        bucket = lookup_bucket(ht, size, bit_reverse_ulong(old_node->reverse_hash));
        _cds_lfht_gc_bucket(bucket, new_node);
 
-       assert(is_removed(CMM_LOAD_SHARED(old_node->next)));
+       urcu_posix_assert(is_removed(CMM_LOAD_SHARED(old_node->next)));
        return 0;
 }
 
@@ -1058,9 +1058,9 @@ void _cds_lfht_add(struct cds_lfht *ht,
                        *return_node;
        struct cds_lfht_node *bucket;
 
-       assert(!is_bucket(node));
-       assert(!is_removed(node));
-       assert(!is_removal_owner(node));
+       urcu_posix_assert(!is_bucket(node));
+       urcu_posix_assert(!is_removed(node));
+       urcu_posix_assert(!is_removal_owner(node));
        bucket = lookup_bucket(ht, size, hash);
        for (;;) {
                uint32_t chain_len = 0;
@@ -1072,7 +1072,7 @@ void _cds_lfht_add(struct cds_lfht *ht,
                iter_prev = bucket;
                /* We can always skip the bucket node initially */
                iter = rcu_dereference(iter_prev->next);
-               assert(iter_prev->reverse_hash <= node->reverse_hash);
+               urcu_posix_assert(iter_prev->reverse_hash <= node->reverse_hash);
                for (;;) {
                        if (caa_unlikely(is_end(iter)))
                                goto insert;
@@ -1125,12 +1125,12 @@ void _cds_lfht_add(struct cds_lfht *ht,
                }
 
        insert:
-               assert(node != clear_flag(iter));
-               assert(!is_removed(iter_prev));
-               assert(!is_removal_owner(iter_prev));
-               assert(!is_removed(iter));
-               assert(!is_removal_owner(iter));
-               assert(iter_prev != node);
+               urcu_posix_assert(node != clear_flag(iter));
+               urcu_posix_assert(!is_removed(iter_prev));
+               urcu_posix_assert(!is_removal_owner(iter_prev));
+               urcu_posix_assert(!is_removed(iter));
+               urcu_posix_assert(!is_removal_owner(iter));
+               urcu_posix_assert(iter_prev != node);
                if (!bucket_flag)
                        node->next = clear_flag(iter);
                else
@@ -1148,8 +1148,8 @@ void _cds_lfht_add(struct cds_lfht *ht,
                }
 
        gc_node:
-               assert(!is_removed(iter));
-               assert(!is_removal_owner(iter));
+               urcu_posix_assert(!is_removed(iter));
+               urcu_posix_assert(!is_removal_owner(iter));
                if (is_bucket(iter))
                        new_next = flag_bucket(clear_flag(next));
                else
@@ -1174,9 +1174,9 @@ int _cds_lfht_del(struct cds_lfht *ht, unsigned long size,
                return -ENOENT;
 
        /* logically delete the node */
-       assert(!is_bucket(node));
-       assert(!is_removed(node));
-       assert(!is_removal_owner(node));
+       urcu_posix_assert(!is_bucket(node));
+       urcu_posix_assert(!is_removed(node));
+       urcu_posix_assert(!is_removal_owner(node));
 
        /*
         * We are first checking if the node had previously been
@@ -1187,7 +1187,7 @@ int _cds_lfht_del(struct cds_lfht *ht, unsigned long size,
        next = CMM_LOAD_SHARED(node->next);     /* next is not dereferenced */
        if (caa_unlikely(is_removed(next)))
                return -ENOENT;
-       assert(!is_bucket(next));
+       urcu_posix_assert(!is_bucket(next));
        /*
         * The del operation semantic guarantees a full memory barrier
         * before the uatomic_or atomic commit of the deletion flag.
@@ -1210,7 +1210,7 @@ int _cds_lfht_del(struct cds_lfht *ht, unsigned long size,
        bucket = lookup_bucket(ht, size, bit_reverse_ulong(node->reverse_hash));
        _cds_lfht_gc_bucket(bucket, node);
 
-       assert(is_removed(CMM_LOAD_SHARED(node->next)));
+       urcu_posix_assert(is_removed(CMM_LOAD_SHARED(node->next)));
        /*
         * Last phase: atomically exchange node->next with a version
         * having "REMOVAL_OWNER_FLAG" set. If the returned node->next
@@ -1252,7 +1252,7 @@ void partition_resize_helper(struct cds_lfht *ht, unsigned long i,
        int ret;
        unsigned long thread, nr_threads;
 
-       assert(nr_cpus_mask != -1);
+       urcu_posix_assert(nr_cpus_mask != -1);
        if (nr_cpus_mask < 0 || len < 2 * MIN_PARTITION_PER_THREAD)
                goto fallback;
 
@@ -1292,11 +1292,11 @@ void partition_resize_helper(struct cds_lfht *ht, unsigned long i,
                        nr_threads = thread;
                        break;
                }
-               assert(!ret);
+               urcu_posix_assert(!ret);
        }
        for (thread = 0; thread < nr_threads; thread++) {
                ret = pthread_join(work[thread].thread_id, NULL);
-               assert(!ret);
+               urcu_posix_assert(!ret);
        }
        free(work);
 
@@ -1328,12 +1328,12 @@ void init_table_populate_partition(struct cds_lfht *ht, unsigned long i,
 {
        unsigned long j, size = 1UL << (i - 1);
 
-       assert(i > MIN_TABLE_ORDER);
+       urcu_posix_assert(i > MIN_TABLE_ORDER);
        ht->flavor->read_lock();
        for (j = size + start; j < size + start + len; j++) {
                struct cds_lfht_node *new_node = bucket_at(ht, j);
 
-               assert(j >= size && j < (size << 1));
+               urcu_posix_assert(j >= size && j < (size << 1));
                dbg_printf("init populate: order %lu index %lu hash %lu\n",
                           i, j, j);
                new_node->reverse_hash = bit_reverse_ulong(j);
@@ -1357,7 +1357,7 @@ void init_table(struct cds_lfht *ht,
 
        dbg_printf("init table: first_order %lu last_order %lu\n",
                   first_order, last_order);
-       assert(first_order > MIN_TABLE_ORDER);
+       urcu_posix_assert(first_order > MIN_TABLE_ORDER);
        for (i = first_order; i <= last_order; i++) {
                unsigned long len;
 
@@ -1420,13 +1420,13 @@ void remove_table_partition(struct cds_lfht *ht, unsigned long i,
 {
        unsigned long j, size = 1UL << (i - 1);
 
-       assert(i > MIN_TABLE_ORDER);
+       urcu_posix_assert(i > MIN_TABLE_ORDER);
        ht->flavor->read_lock();
        for (j = size + start; j < size + start + len; j++) {
                struct cds_lfht_node *fini_bucket = bucket_at(ht, j);
                struct cds_lfht_node *parent_bucket = bucket_at(ht, j - size);
 
-               assert(j >= size && j < (size << 1));
+               urcu_posix_assert(j >= size && j < (size << 1));
                dbg_printf("remove entry: order %lu index %lu hash %lu\n",
                           i, j, j);
                /* Set the REMOVED_FLAG to freeze the ->next for gc */
@@ -1455,7 +1455,7 @@ void fini_table(struct cds_lfht *ht,
 
        dbg_printf("fini table: first_order %lu last_order %lu\n",
                   first_order, last_order);
-       assert(first_order > MIN_TABLE_ORDER);
+       urcu_posix_assert(first_order > MIN_TABLE_ORDER);
        for (i = last_order; i >= first_order; i--) {
                unsigned long len;
 
@@ -1518,7 +1518,7 @@ void cds_lfht_create_bucket(struct cds_lfht *ht, unsigned long size)
        node->reverse_hash = 0;
 
        bucket_order = cds_lfht_get_count_order_ulong(size);
-       assert(bucket_order >= 0);
+       urcu_posix_assert(bucket_order >= 0);
 
        for (order = 1; order < (unsigned long) bucket_order + 1; order++) {
                len = 1UL << (order - 1);
@@ -1544,7 +1544,7 @@ void cds_lfht_create_bucket(struct cds_lfht *ht, unsigned long size)
                        node->reverse_hash = bit_reverse_ulong(len + i);
 
                        /* insert after prev */
-                       assert(is_bucket(prev->next));
+                       urcu_posix_assert(is_bucket(prev->next));
                        node->next = prev->next;
                        prev->next = flag_bucket(node);
                }
@@ -1620,9 +1620,9 @@ struct cds_lfht *_cds_lfht_new(unsigned long init_size,
        init_size = min(init_size, max_nr_buckets);
 
        ht = mm->alloc_cds_lfht(min_nr_alloc_buckets, max_nr_buckets);
-       assert(ht);
-       assert(ht->mm == mm);
-       assert(ht->bucket_at == mm->bucket_at);
+       urcu_posix_assert(ht);
+       urcu_posix_assert(ht->mm == mm);
+       urcu_posix_assert(ht->bucket_at == mm->bucket_at);
 
        ht->flags = flags;
        ht->flavor = flavor;
@@ -1663,7 +1663,7 @@ void cds_lfht_lookup(struct cds_lfht *ht, unsigned long hash,
                        break;
                }
                next = rcu_dereference(node->next);
-               assert(node == clear_flag(node));
+               urcu_posix_assert(node == clear_flag(node));
                if (caa_likely(!is_removed(next))
                    && !is_bucket(next)
                    && node->reverse_hash == reverse_hash
@@ -1672,7 +1672,7 @@ void cds_lfht_lookup(struct cds_lfht *ht, unsigned long hash,
                }
                node = clear_flag(next);
        }
-       assert(!node || !is_bucket(CMM_LOAD_SHARED(node->next)));
+       urcu_posix_assert(!node || !is_bucket(CMM_LOAD_SHARED(node->next)));
        iter->node = node;
        iter->next = next;
 }
@@ -1707,7 +1707,7 @@ void cds_lfht_next_duplicate(struct cds_lfht *ht __attribute__((unused)),
                }
                node = clear_flag(next);
        }
-       assert(!node || !is_bucket(CMM_LOAD_SHARED(node->next)));
+       urcu_posix_assert(!node || !is_bucket(CMM_LOAD_SHARED(node->next)));
        iter->node = node;
        iter->next = next;
 }
@@ -1731,7 +1731,7 @@ void cds_lfht_next(struct cds_lfht *ht __attribute__((unused)),
                }
                node = clear_flag(next);
        }
-       assert(!node || !is_bucket(CMM_LOAD_SHARED(node->next)));
+       urcu_posix_assert(!node || !is_bucket(CMM_LOAD_SHARED(node->next)));
        iter->node = node;
        iter->next = next;
 }
@@ -1852,8 +1852,8 @@ int cds_lfht_delete_bucket(struct cds_lfht *ht)
                node = clear_flag(node)->next;
                if (!is_bucket(node))
                        return -EPERM;
-               assert(!is_removed(node));
-               assert(!is_removal_owner(node));
+               urcu_posix_assert(!is_removed(node));
+               urcu_posix_assert(!is_removal_owner(node));
        } while (!is_end(node));
        /*
         * size accessed without rcu_dereference because hash table is
@@ -1865,7 +1865,7 @@ int cds_lfht_delete_bucket(struct cds_lfht *ht)
                node = bucket_at(ht, i);
                dbg_printf("delete bucket: index %lu expected hash %lu hash %lu\n",
                        i, i, bit_reverse_ulong(node->reverse_hash));
-               assert(is_bucket(node->next));
+               urcu_posix_assert(is_bucket(node->next));
        }
 
        for (order = cds_lfht_get_count_order_ulong(size); (long)order >= 0; order--)
@@ -1962,7 +1962,7 @@ void _do_cds_lfht_grow(struct cds_lfht *ht,
        new_order = cds_lfht_get_count_order_ulong(new_size);
        dbg_printf("resize from %lu (order %lu) to %lu (order %lu) buckets\n",
                   old_size, old_order, new_size, new_order);
-       assert(new_size > old_size);
+       urcu_posix_assert(new_size > old_size);
        init_table(ht, old_order + 1, new_order);
 }
 
@@ -1978,7 +1978,7 @@ void _do_cds_lfht_shrink(struct cds_lfht *ht,
        new_order = cds_lfht_get_count_order_ulong(new_size);
        dbg_printf("resize from %lu (order %lu) to %lu (order %lu) buckets\n",
                   old_size, old_order, new_size, new_order);
-       assert(new_size < old_size);
+       urcu_posix_assert(new_size < old_size);
 
        /* Remove and unlink all bucket nodes to remove. */
        fini_table(ht, new_order + 1, old_order);
index 83df1399cd382280e8cedc67a2bf0c854098fa2c..a097d7f00312a1372123f5c61a732f0e8270354d 100644 (file)
@@ -28,7 +28,6 @@
 #include <stdio.h>
 #include <pthread.h>
 #include <signal.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -37,6 +36,7 @@
 #include <stdbool.h>
 #include <sys/mman.h>
 
+#include <urcu/assert.h>
 #include <urcu/config.h>
 #include <urcu/arch.h>
 #include <urcu/wfcqueue.h>
@@ -80,7 +80,7 @@ void *mremap_wrapper(void *old_address __attribute__((unused)),
                size_t new_size __attribute__((unused)),
                int flags)
 {
-       assert(!(flags & MREMAP_MAYMOVE));
+       urcu_posix_assert(!(flags & MREMAP_MAYMOVE));
 
        return MAP_FAILED;
 }
@@ -277,9 +277,9 @@ void urcu_bp_synchronize_rcu(void)
        int ret;
 
        ret = sigfillset(&newmask);
-       assert(!ret);
+       urcu_posix_assert(!ret);
        ret = pthread_sigmask(SIG_BLOCK, &newmask, &oldmask);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 
        mutex_lock(&rcu_gp_lock);
 
@@ -345,7 +345,7 @@ out:
        mutex_unlock(&rcu_registry_lock);
        mutex_unlock(&rcu_gp_lock);
        ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 /*
@@ -383,7 +383,7 @@ void expand_arena(struct registry_arena *arena)
 
        /* No chunk. */
        if (cds_list_empty(&arena->chunk_list)) {
-               assert(ARENA_INIT_ALLOC >=
+               urcu_posix_assert(ARENA_INIT_ALLOC >=
                        sizeof(struct registry_chunk)
                        + sizeof(struct rcu_reader));
                new_chunk_len = ARENA_INIT_ALLOC;
@@ -413,7 +413,7 @@ void expand_arena(struct registry_arena *arena)
                new_chunk_len, 0);
        if (new_chunk != MAP_FAILED) {
                /* Should not have moved. */
-               assert(new_chunk == last_chunk);
+               urcu_posix_assert(new_chunk == last_chunk);
                memset((char *) last_chunk + old_chunk_len, 0,
                        new_chunk_len - old_chunk_len);
                last_chunk->data_len =
@@ -484,7 +484,7 @@ void add_thread(void)
 
        /* Add to registry */
        rcu_reader_reg->tid = pthread_self();
-       assert(rcu_reader_reg->ctr == 0);
+       urcu_posix_assert(rcu_reader_reg->ctr == 0);
        cds_list_add(&rcu_reader_reg->node, &registry);
        /*
         * Reader threads are pointing to the reader registry. This is
@@ -685,9 +685,9 @@ void urcu_bp_before_fork(void)
        int ret;
 
        ret = sigfillset(&newmask);
-       assert(!ret);
+       urcu_posix_assert(!ret);
        ret = pthread_sigmask(SIG_BLOCK, &newmask, &oldmask);
-       assert(!ret);
+       urcu_posix_assert(!ret);
        mutex_lock(&rcu_gp_lock);
        mutex_lock(&rcu_registry_lock);
        saved_fork_signal_mask = oldmask;
@@ -702,7 +702,7 @@ void urcu_bp_after_fork_parent(void)
        mutex_unlock(&rcu_registry_lock);
        mutex_unlock(&rcu_gp_lock);
        ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 /*
@@ -738,7 +738,7 @@ void urcu_bp_after_fork_child(void)
        mutex_unlock(&rcu_registry_lock);
        mutex_unlock(&rcu_gp_lock);
        ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 void *urcu_bp_dereference_sym(void *p)
index 288686528997004c890cea7f31dc6af2af5e5398..4392bc6b87ad53d290847ab246ff824fc0f244ea 100644 (file)
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <pthread.h>
 #include <signal.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
@@ -35,6 +34,7 @@
 #include <sched.h>
 
 #include "compat-getcpu.h"
+#include <urcu/assert.h>
 #include <urcu/wfcqueue.h>
 #include <urcu/call-rcu.h>
 #include <urcu/pointer.h>
@@ -355,8 +355,8 @@ static void *call_rcu_thread(void *arg)
                cds_wfcq_init(&cbs_tmp_head, &cbs_tmp_tail);
                splice_ret = __cds_wfcq_splice_blocking(&cbs_tmp_head,
                        &cbs_tmp_tail, &crdp->cbs_head, &crdp->cbs_tail);
-               assert(splice_ret != CDS_WFCQ_RET_WOULDBLOCK);
-               assert(splice_ret != CDS_WFCQ_RET_DEST_NON_EMPTY);
+               urcu_posix_assert(splice_ret != CDS_WFCQ_RET_WOULDBLOCK);
+               urcu_posix_assert(splice_ret != CDS_WFCQ_RET_DEST_NON_EMPTY);
                if (splice_ret != CDS_WFCQ_RET_SRC_EMPTY) {
                        synchronize_rcu();
                        cbcount = 0;
index 8b5ad972421d52f523f18146a3a1a068c2bcb661..d25e9b93f4dc17e8f1e6ee986ad04cdca366527f 100644 (file)
@@ -33,7 +33,6 @@
 #include <pthread.h>
 #include <stdio.h>
 #include <signal.h>
-#include <assert.h>
 #include <string.h>
 #include <errno.h>
 #include <poll.h>
@@ -43,6 +42,7 @@
 
 #include "urcu/futex.h"
 
+#include <urcu/assert.h>
 #include <urcu/compiler.h>
 #include <urcu/arch.h>
 #include <urcu/uatomic.h>
@@ -325,9 +325,9 @@ static void _defer_rcu(void (*fct)(void *p), void *p)
         * Worse-case: must allow 2 supplementary entries for fct pointer.
         */
        if (caa_unlikely(head - tail >= DEFER_QUEUE_SIZE - 2)) {
-               assert(head - tail <= DEFER_QUEUE_SIZE);
+               urcu_posix_assert(head - tail <= DEFER_QUEUE_SIZE);
                rcu_defer_barrier_thread();
-               assert(head - CMM_LOAD_SHARED(URCU_TLS(defer_queue).tail) == 0);
+               urcu_posix_assert(head - CMM_LOAD_SHARED(URCU_TLS(defer_queue).tail) == 0);
        }
 
        /*
@@ -403,7 +403,7 @@ static void start_defer_thread(void)
        int ret;
 
        ret = pthread_create(&tid_defer, NULL, thr_defer, NULL);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 }
 
 static void stop_defer_thread(void)
@@ -417,19 +417,19 @@ static void stop_defer_thread(void)
        wake_up_defer();
 
        ret = pthread_join(tid_defer, &tret);
-       assert(!ret);
+       urcu_posix_assert(!ret);
 
        CMM_STORE_SHARED(defer_thread_stop, 0);
        /* defer thread should always exit when futex value is 0 */
-       assert(uatomic_read(&defer_thread_futex) == 0);
+       urcu_posix_assert(uatomic_read(&defer_thread_futex) == 0);
 }
 
 int rcu_defer_register_thread(void)
 {
        int was_empty;
 
-       assert(URCU_TLS(defer_queue).last_head == 0);
-       assert(URCU_TLS(defer_queue).q == NULL);
+       urcu_posix_assert(URCU_TLS(defer_queue).last_head == 0);
+       urcu_posix_assert(URCU_TLS(defer_queue).q == NULL);
        URCU_TLS(defer_queue).q = malloc(sizeof(void *) * DEFER_QUEUE_SIZE);
        if (!URCU_TLS(defer_queue).q)
                return -ENOMEM;
@@ -466,7 +466,7 @@ void rcu_defer_unregister_thread(void)
 
 void rcu_defer_exit(void)
 {
-       assert(cds_list_empty(&registry_defer));
+       urcu_posix_assert(cds_list_empty(&registry_defer));
 }
 
 #endif /* _URCU_DEFER_IMPL_H */
index e934d3b57f7681225e1577089fdd589b17a6ad33..d69d93b1018e2740a0bf9f6fec877a012820f1e8 100644 (file)
 #include <stdio.h>
 #include <pthread.h>
 #include <signal.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
 #include <errno.h>
 #include <poll.h>
 
+#include <urcu/assert.h>
 #include <urcu/wfcqueue.h>
 #include <urcu/map/urcu-qsbr.h>
 #define BUILD_QSBR_LIB
@@ -470,10 +470,10 @@ void urcu_qsbr_thread_online(void)
 void urcu_qsbr_register_thread(void)
 {
        URCU_TLS(urcu_qsbr_reader).tid = pthread_self();
-       assert(URCU_TLS(urcu_qsbr_reader).ctr == 0);
+       urcu_posix_assert(URCU_TLS(urcu_qsbr_reader).ctr == 0);
 
        mutex_lock(&rcu_registry_lock);
-       assert(!URCU_TLS(urcu_qsbr_reader).registered);
+       urcu_posix_assert(!URCU_TLS(urcu_qsbr_reader).registered);
        URCU_TLS(urcu_qsbr_reader).registered = 1;
        cds_list_add(&URCU_TLS(urcu_qsbr_reader).node, &registry);
        mutex_unlock(&rcu_registry_lock);
@@ -487,7 +487,7 @@ void urcu_qsbr_unregister_thread(void)
         * with a waiting writer.
         */
        _urcu_qsbr_thread_offline();
-       assert(URCU_TLS(urcu_qsbr_reader).registered);
+       urcu_posix_assert(URCU_TLS(urcu_qsbr_reader).registered);
        URCU_TLS(urcu_qsbr_reader).registered = 0;
        mutex_lock(&rcu_registry_lock);
        cds_list_del(&URCU_TLS(urcu_qsbr_reader).node);
@@ -499,7 +499,7 @@ void urcu_qsbr_exit(void)
        /*
         * Assertion disabled because call_rcu threads are now rcu
         * readers, and left running at exit.
-        * assert(cds_list_empty(&registry));
+        * urcu_posix_assert(cds_list_empty(&registry));
         */
 }
 
index 47ac5eb35884f437ca299e48cf656e2c301557f7..c586ec9da8a007519cc7d6a793a9b6598cea46be 100644 (file)
@@ -23,6 +23,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <urcu/assert.h>
 #include <urcu/uatomic.h>
 #include <urcu/wfstack.h>
 #include "urcu-die.h"
@@ -126,7 +127,7 @@ static inline
 void urcu_adaptative_wake_up(struct urcu_wait_node *wait)
 {
        cmm_smp_mb();
-       assert(uatomic_read(&wait->state) == URCU_WAIT_WAITING);
+       urcu_posix_assert(uatomic_read(&wait->state) == URCU_WAIT_WAITING);
        uatomic_set(&wait->state, URCU_WAIT_WAKEUP);
        if (!(uatomic_read(&wait->state) & URCU_WAIT_RUNNING)) {
                if (futex_noasync(&wait->state, FUTEX_WAKE, 1,
@@ -183,7 +184,7 @@ skip_futex_wait:
        }
        while (!(uatomic_read(&wait->state) & URCU_WAIT_TEARDOWN))
                poll(NULL, 0, 10);
-       assert(uatomic_read(&wait->state) & URCU_WAIT_TEARDOWN);
+       urcu_posix_assert(uatomic_read(&wait->state) & URCU_WAIT_TEARDOWN);
 }
 
 static inline
index 902b8f839a75b4df7e0b077ed780a2f0b0c4a433..67c6525ddc9479cd0c63de0805998c99fa32b07c 100644 (file)
@@ -30,7 +30,6 @@
 #include <stdio.h>
 #include <pthread.h>
 #include <signal.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
@@ -39,6 +38,7 @@
 #include <poll.h>
 
 #include <urcu/config.h>
+#include <urcu/assert.h>
 #include <urcu/arch.h>
 #include <urcu/wfcqueue.h>
 #include <urcu/map/urcu.h>
@@ -532,11 +532,11 @@ int rcu_read_ongoing(void)
 void rcu_register_thread(void)
 {
        URCU_TLS(rcu_reader).tid = pthread_self();
-       assert(URCU_TLS(rcu_reader).need_mb == 0);
-       assert(!(URCU_TLS(rcu_reader).ctr & URCU_GP_CTR_NEST_MASK));
+       urcu_posix_assert(URCU_TLS(rcu_reader).need_mb == 0);
+       urcu_posix_assert(!(URCU_TLS(rcu_reader).ctr & URCU_GP_CTR_NEST_MASK));
 
        mutex_lock(&rcu_registry_lock);
-       assert(!URCU_TLS(rcu_reader).registered);
+       urcu_posix_assert(!URCU_TLS(rcu_reader).registered);
        URCU_TLS(rcu_reader).registered = 1;
        rcu_init();     /* In case gcc does not support constructor attribute */
        cds_list_add(&URCU_TLS(rcu_reader).node, &registry);
@@ -546,7 +546,7 @@ void rcu_register_thread(void)
 void rcu_unregister_thread(void)
 {
        mutex_lock(&rcu_registry_lock);
-       assert(URCU_TLS(rcu_reader).registered);
+       urcu_posix_assert(URCU_TLS(rcu_reader).registered);
        URCU_TLS(rcu_reader).registered = 0;
        cds_list_del(&URCU_TLS(rcu_reader).node);
        mutex_unlock(&rcu_registry_lock);
@@ -648,7 +648,7 @@ void rcu_exit(void)
         * application exits.
         * Assertion disabled because call_rcu threads are now rcu
         * readers, and left running at exit.
-        * assert(cds_list_empty(&registry));
+        * urcu_posix_assert(cds_list_empty(&registry));
         */
 }
 
index cadcf874be6c76726dc1a3dd3e082c545b266e8b..e5931b5e74bfee68c3efd1ff61b53e9bc68af23f 100644 (file)
@@ -25,7 +25,6 @@
 #include <stdio.h>
 #include <pthread.h>
 #include <signal.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
@@ -36,6 +35,7 @@
 #include <sched.h>
 
 #include "compat-getcpu.h"
+#include <urcu/assert.h>
 #include <urcu/wfcqueue.h>
 #include <urcu/pointer.h>
 #include <urcu/list.h>
@@ -210,8 +210,8 @@ static void *workqueue_thread(void *arg)
                cds_wfcq_init(&cbs_tmp_head, &cbs_tmp_tail);
                splice_ret = __cds_wfcq_splice_blocking(&cbs_tmp_head,
                        &cbs_tmp_tail, &workqueue->cbs_head, &workqueue->cbs_tail);
-               assert(splice_ret != CDS_WFCQ_RET_WOULDBLOCK);
-               assert(splice_ret != CDS_WFCQ_RET_DEST_NON_EMPTY);
+               urcu_posix_assert(splice_ret != CDS_WFCQ_RET_WOULDBLOCK);
+               urcu_posix_assert(splice_ret != CDS_WFCQ_RET_DEST_NON_EMPTY);
                if (splice_ret != CDS_WFCQ_RET_SRC_EMPTY) {
                        if (workqueue->grace_period_fct)
                                workqueue->grace_period_fct(workqueue, workqueue->priv);
@@ -336,7 +336,7 @@ void urcu_workqueue_destroy(struct urcu_workqueue *workqueue)
        if (urcu_workqueue_destroy_worker(workqueue)) {
                urcu_die(errno);
        }
-       assert(cds_wfcq_empty(&workqueue->cbs_head, &workqueue->cbs_tail));
+       urcu_posix_assert(cds_wfcq_empty(&workqueue->cbs_head, &workqueue->cbs_tail));
        free(workqueue);
 }
 
index 51c1744b4f979d64a436256cdb456530aa250e98..d969ffcc00b2d58c0add83a53df2c31148d3aefd 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <sched.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 
 #ifndef DYNAMIC_LINK_TEST
 #define _LGPL_SOURCE
index 6c4e8c773ed31a8e4f64da363ce0d4e4b204382e..55f7c38f21bf66f2d8ad7dbb91cb778256b6ccb4 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 
@@ -156,7 +156,7 @@ void *thr_reader(void *data)
 
                pthread_mutex_lock(&lock);
                v = test_array.a;
-               assert(v == 8);
+               urcu_posix_assert(v == 8);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                pthread_mutex_unlock(&lock);
index 76cdee9afa306fa06adfa26f32ce246789c54090..47a512cba06b12d8672247710db5feabdd2e3c45 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 
@@ -184,7 +184,7 @@ void *thr_reader(void *data)
 
                urcu_mutex_lock(&per_thread_lock[tidx].lock);
                v = test_array.a;
-               assert(v == 8);
+               urcu_posix_assert(v == 8);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                urcu_mutex_unlock(&per_thread_lock[tidx].lock);
index 712eca1b2806e920832c016c93d550147ac98e9d..34aae5fdba7918c1623b963deb5367ca195e571b 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <pthread.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 
 #include "thread-id.h"
 
@@ -87,7 +87,7 @@ void *thr_reader(void *arg)
                                perror("Error in pthread mutex lock");
                                exit(-1);
                        }
-                       assert(test_array.a == 8);
+                       urcu_posix_assert(test_array.a == 8);
                        ret = pthread_mutex_unlock(&per_thread_lock[tidx].lock);
                        if (ret) {
                                perror("Error in pthread mutex unlock");
index 7ee73b42a25f162e024edcff3fdb8b4c8ce41171..6908ea4ca5b4a7f315d76a5212640adface5073a 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 
@@ -161,7 +161,7 @@ void *thr_reader(void *_count)
                }
 
                a = test_array.a;
-               assert(a == 8);
+               urcu_posix_assert(a == 8);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
 
index a7d035ea5c92ddcca2046939db56ce36bce688ee..99c957c148c3b92629505a998bcb270aeef6aaa3 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <pthread.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 
 #include "thread-id.h"
 
@@ -87,7 +87,7 @@ void *thr_reader(void *arg)
                                abort();
                        }
 
-                       assert(test_array.a == 8);
+                       urcu_posix_assert(test_array.a == 8);
 
                        ret = pthread_rwlock_unlock(&lock);
                        if (ret) {
index 2f41a82fcc54bd17d3940ca389985bc3f3e1f3e0..ea849fa7c481ce37cdf5dd9a384b12043d5b13b4 100644 (file)
@@ -28,9 +28,9 @@
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
+#include <urcu/assert.h>
 #include <urcu/arch.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
@@ -140,7 +140,7 @@ void *thr_reader(void *_count)
        set_affinity();
 
        rcu_register_thread();
-       assert(!rcu_read_ongoing());
+       urcu_posix_assert(!rcu_read_ongoing());
 
        while (!test_go)
        {
@@ -149,11 +149,11 @@ void *thr_reader(void *_count)
 
        for (;;) {
                rcu_read_lock();
-               assert(rcu_read_ongoing());
+               urcu_posix_assert(rcu_read_ongoing());
                local_ptr = rcu_dereference(test_rcu_pointer);
                rcu_debug_yield_read();
                if (local_ptr)
-                       assert(*local_ptr == 8);
+                       urcu_posix_assert(*local_ptr == 8);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                rcu_read_unlock();
@@ -193,7 +193,7 @@ void *thr_writer(void *_count)
 
        for (;;) {
                new = malloc(sizeof(int));
-               assert(new);
+               urcu_posix_assert(new);
                *new = 8;
                old = rcu_xchg_pointer(&test_rcu_pointer, new);
                if (caa_unlikely(wduration))
index dcb5d1e74fa7904a0bcafd06de05e1df48354a5b..88889a89d0421097b90177f1853f7ac3fa5cb0db 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 #include "../common/debug-yield.h"
@@ -172,7 +172,7 @@ static struct test_array *test_array_alloc(void)
        int index;
 
        index = array_index % ARRAY_SIZE;
-       assert(test_array[index].a == ARRAY_POISON ||
+       urcu_posix_assert(test_array[index].a == ARRAY_POISON ||
                test_array[index].a == 0);
        ret = &test_array[index];
        array_index++;
@@ -211,7 +211,7 @@ void *thr_reader(void *_count)
                local_ptr = rcu_dereference(test_rcu_pointer);
                rcu_debug_yield_read();
                if (local_ptr)
-                       assert(local_ptr->a == 8);
+                       urcu_posix_assert(local_ptr->a == 8);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                rcu_read_unlock();
index 1bf62bddfc6d885be585c1be681368035738113d..6f8c59d67500d548a8ffec10f0272ff5a1ed8f51 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 #include "../common/debug-yield.h"
@@ -140,7 +140,7 @@ void *thr_reader(void *_count)
        set_affinity();
 
        rcu_register_thread();
-       assert(!rcu_read_ongoing());
+       urcu_posix_assert(!rcu_read_ongoing());
 
        while (!test_go)
        {
@@ -149,11 +149,11 @@ void *thr_reader(void *_count)
 
        for (;;) {
                rcu_read_lock();
-               assert(rcu_read_ongoing());
+               urcu_posix_assert(rcu_read_ongoing());
                local_ptr = rcu_dereference(test_rcu_pointer);
                rcu_debug_yield_read();
                if (local_ptr)
-                       assert(*local_ptr == 8);
+                       urcu_posix_assert(*local_ptr == 8);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                rcu_read_unlock();
index 3635f1a49093c4af8d58a16763f565d3c8d1b5fd..e948ebff8e942d7dc0c21fe29e61b1f38dd5f1bd 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 #include "../common/debug-yield.h"
@@ -159,7 +159,7 @@ void *thr_reader(void *_count)
                local_ptr = rcu_dereference(test_rcu_pointer);
                rcu_debug_yield_read();
                if (local_ptr)
-                       assert(local_ptr->a == 8);
+                       urcu_posix_assert(local_ptr->a == 8);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                rcu_read_unlock();
index 50c5b76326e8c28aab567001f31c38dde32f5796..f14f7286f4dcd4e7c20551fcd497e0f3feaab58a 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 #include "../common/debug-yield.h"
@@ -167,7 +167,7 @@ void *thr_reader(void *_count)
                local_ptr = rcu_dereference(test_rcu_pointer);
                rcu_debug_yield_read();
                if (local_ptr)
-                       assert(local_ptr->a == 8);
+                       urcu_posix_assert(local_ptr->a == 8);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                rcu_read_unlock();
index 8838bc097130b065faeddaf78ec3fefa16c6092d..3574b4c3468117cce094344fcb170f390e06d8d1 100644 (file)
@@ -192,7 +192,7 @@ unsigned long test_compare(const void *key1, size_t key1_len,
 {
        if (caa_unlikely(key1_len != key2_len))
                return -1;
-       assert(key1_len == sizeof(unsigned long));
+       urcu_posix_assert(key1_len == sizeof(unsigned long));
        if (key1 == key2)
                return 0;
        else
@@ -258,7 +258,7 @@ void test_delete_all_nodes(struct cds_lfht *ht)
                int ret;
 
                ret = cds_lfht_del(test_ht, cds_lfht_iter_get_node(&iter));
-               assert(!ret);
+               urcu_posix_assert(!ret);
                call_rcu(&node->head, free_node_cb);
                count++;
        }
@@ -599,7 +599,7 @@ int main(int argc, char **argv)
         */
        rcu_register_thread();
        ret = (get_populate_hash_cb())();
-       assert(!ret);
+       urcu_posix_assert(!ret);
 
        rcu_thread_offline();
 
index dfb8116a1fd2651ebcc6f565d3d9826beb86ce62..47b2ae3ea5f3523c06a5a67fb835b823ebe78fcf 100644 (file)
 #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 <compat-rand.h>
 #include "thread-id.h"
@@ -304,7 +304,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
@@ -320,7 +320,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]);
@@ -345,7 +345,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;
        }
@@ -367,7 +367,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);
index 708e29b531bac2799a28db81fe636c0330338a67..490e8b0527154f3f55edcf9beb0c44e0a1080aa5 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 
@@ -404,7 +404,7 @@ int main(int argc, char **argv)
 
        test_end(&end_dequeues);
        err = cds_lfq_destroy_rcu(&q);
-       assert(!err);
+       urcu_posix_assert(!err);
 
        printf_verbose("total number of enqueues : %llu, dequeues %llu\n",
                       tot_enqueues, tot_dequeues);
index 1d1ae52064e97b592a10b623f2030c48b6a0716f..52239e02360931be91738c30753a6f5f522892ac 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 
@@ -266,7 +266,7 @@ static void *thr_dequeuer(void *_count)
        }
        cmm_smp_mb();
 
-       assert(test_pop || test_pop_all);
+       urcu_posix_assert(test_pop || test_pop_all);
 
        for (;;) {
                if (test_pop && test_pop_all) {
index 7b5c0553eb257fdb15f251ca9e887787ecb00cca..7975fafd14585cc43372641e1eca5728e73a3742 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 
index 6a5174472b2c86b934edf812cd7a62a963b52fae..1ea369cbea9203fa690bee1d80c96f63fff488a4 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 #include "../common/debug-yield.h"
@@ -140,9 +140,9 @@ void *thr_reader(void *_count)
 
        rcu_register_thread();
 
-       assert(rcu_read_ongoing());
+       urcu_posix_assert(rcu_read_ongoing());
        rcu_thread_offline();
-       assert(!rcu_read_ongoing());
+       urcu_posix_assert(!rcu_read_ongoing());
        rcu_thread_online();
 
        while (!test_go)
@@ -152,11 +152,11 @@ void *thr_reader(void *_count)
 
        for (;;) {
                rcu_read_lock();
-               assert(rcu_read_ongoing());
+               urcu_posix_assert(rcu_read_ongoing());
                local_ptr = rcu_dereference(test_rcu_pointer);
                rcu_debug_yield_read();
                if (local_ptr)
-                       assert(*local_ptr == 8);
+                       urcu_posix_assert(*local_ptr == 8);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                rcu_read_unlock();
@@ -199,7 +199,7 @@ void *thr_writer(void *_count)
 
        for (;;) {
                new = malloc(sizeof(int));
-               assert(new);
+               urcu_posix_assert(new);
                *new = 8;
                old = rcu_xchg_pointer(&test_rcu_pointer, new);
                if (caa_unlikely(wduration))
index 8eaf8d48b4a4489aba66a2bb5bbd0bed7463f567..8877a8213d3cbb466c5a98f07d364204fa0dc2c5 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 #include "../common/debug-yield.h"
@@ -164,7 +164,7 @@ void *thr_reader(void *_count)
                local_ptr = _rcu_dereference(test_rcu_pointer);
                rcu_debug_yield_read();
                if (local_ptr)
-                       assert(local_ptr->a == 8);
+                       urcu_posix_assert(local_ptr->a == 8);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                _rcu_read_unlock();
index 71d8d8d806179b23c11c2b978892ba02304e2e1c..09b9ca963c9133496cb3f2cc12512ede8e70089a 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include "thread-id.h"
 
 #define _LGPL_SOURCE
@@ -104,7 +104,7 @@ void *thr_reader(void *arg)
                        _rcu_read_lock();
                        local_ptr = _rcu_dereference(test_rcu_pointer);
                        if (local_ptr) {
-                               assert(local_ptr->a == 8);
+                               urcu_posix_assert(local_ptr->a == 8);
                        }
                        _rcu_read_unlock();
                }
@@ -141,7 +141,7 @@ void *thr_writer(void *arg)
                        rcu_copy_mutex_lock();
                        old = test_rcu_pointer;
                        if (old) {
-                               assert(old->a == 8);
+                               urcu_posix_assert(old->a == 8);
                        }
                        new->a = 8;
                        old = rcu_xchg_pointer(&test_rcu_pointer, new);
index 44911f5c86d807c17bf9cdc263a5a7d205508f14..35b0e80e2b1ce66b28bf95c10ca4a54e98c84f50 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
+
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 
 #include "thread-id.h"
 
@@ -104,7 +105,7 @@ void *thr_reader(void *arg)
                        rcu_read_lock();
                        local_ptr = rcu_dereference(test_rcu_pointer);
                        if (local_ptr) {
-                               assert(local_ptr->a == 8);
+                               urcu_posix_assert(local_ptr->a == 8);
                        }
                        rcu_read_unlock();
                }
@@ -140,7 +141,7 @@ void *thr_writer(void *arg)
                        rcu_copy_mutex_lock();
                        old = test_rcu_pointer;
                        if (old) {
-                               assert(old->a == 8);
+                               urcu_posix_assert(old->a == 8);
                        }
                        new->a = 8;
                        old = rcu_xchg_pointer(&test_rcu_pointer, new);
index 3cae9b75e76fb015d1715291043ade7d9fc8d4fa..2c6e0fd841842b40b6f08fe81cc75db9a6283c49 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include <urcu/uatomic.h>
 #include "thread-id.h"
@@ -233,7 +233,7 @@ static void do_test_splice(enum test_sync sync)
 
        switch (ret) {
        case CDS_WFCQ_RET_WOULDBLOCK:
-               assert(0);      /* blocking call */
+               urcu_posix_assert(0);   /* blocking call */
                break;
        case CDS_WFCQ_RET_DEST_EMPTY:
                URCU_TLS(nr_splice)++;
@@ -241,7 +241,7 @@ static void do_test_splice(enum test_sync sync)
                /* ok */
                break;
        case CDS_WFCQ_RET_DEST_NON_EMPTY:
-               assert(0);      /* entirely unexpected */
+               urcu_posix_assert(0);   /* entirely unexpected */
                break;
        case CDS_WFCQ_RET_SRC_EMPTY:
                /* ok, we could even skip iteration on dest if we wanted */
index 173a567306fb4650e46e1ceea0a4318590a4b0ae..8381160fe8ecd95c0238984137cf861bcb46eafd 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include "thread-id.h"
 
index 64731b3bb6d137dc3d6209a0675e5474fa71c410..c285feb30577a60cca79b8ed055fbb3fbc7fc1d3 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/assert.h>
 #include <urcu/tls-compat.h>
 #include <urcu/uatomic.h>
 #include "thread-id.h"
@@ -255,7 +255,7 @@ static void *thr_dequeuer(void *_count)
        }
        cmm_smp_mb();
 
-       assert(test_pop || test_pop_all);
+       urcu_posix_assert(test_pop || test_pop_all);
 
        for (;;) {
                if (test_pop && test_pop_all) {
index b6f94f55738de8fd8aad241f98b5e3317b99b00c..81dbe7742f769fb5b82db701de9cb515c148c60e 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <assert.h>
 #include <sched.h>
 #include <errno.h>
 
+#include <urcu/assert.h>
 #include <urcu/arch.h>
 #include <urcu/tls-compat.h>
 
@@ -89,7 +89,7 @@ static void test_rcu(void)
        rcu_read_unlock();
 
        node = malloc(sizeof(*node));
-       assert(node);
+       urcu_posix_assert(node);
 
        call_rcu(&node->head, cb);
 
This page took 0.068146 seconds and 4 git commands to generate.