From 2e0fc218783f4fe10081bde5405e2bef8adf7d24 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 20 Mar 2021 23:43:32 +0100 Subject: [PATCH] Fix _push_move of SPSC. It shall take a pointer to the object, not the object itself as argument, just like the other _push_move --- m-buffer.h | 6 +++--- tests/test-mbuffer.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/m-buffer.h b/m-buffer.h index e07dab97..782106b3 100644 --- a/m-buffer.h +++ b/m-buffer.h @@ -1021,7 +1021,7 @@ M_C(name, _init)(buffer_t v, size_t size) \ } \ \ static inline bool \ - M_C(name, _push_move)(buffer_t table, type x) \ + M_C(name, _push_move)(buffer_t table, type *x) \ { \ M_QU3U3_SPSC_CONTRACT(table); \ unsigned int r = atomic_load_explicit(&table->consoIdx, \ @@ -1032,9 +1032,9 @@ M_C(name, _init)(buffer_t v, size_t size) \ return false; \ unsigned int i = w & (table->size -1); \ if (!M_BUFF3R_POLICY_P((policy), BUFFER_PUSH_INIT_POP_MOVE)) { \ - M_DO_MOVE(oplist, table->Tab[i].x, x); \ + M_DO_MOVE(oplist, table->Tab[i].x, *x); \ } else { \ - M_DO_INIT_MOVE(oplist, table->Tab[i].x, x); \ + M_DO_INIT_MOVE(oplist, table->Tab[i].x, *x); \ } \ atomic_store_explicit(&table->prodIdx, w+1, memory_order_release); \ M_QU3U3_SPSC_CONTRACT(table); \ diff --git a/tests/test-mbuffer.c b/tests/test-mbuffer.c index bad6479c..4a7c9eb9 100644 --- a/tests/test-mbuffer.c +++ b/tests/test-mbuffer.c @@ -535,7 +535,8 @@ static void test_spsc(void) b = squeue_uint_pop(&j, q); } while (b); assert(squeue_uint_empty_p(q)); - b = squeue_uint_push_move(q, 65536); + unsigned l = 65536; + b = squeue_uint_push_move(q, &l); assert(b); b = squeue_uint_pop(&j, q); assert(b);