Commit 27d95edd authored by Philippe Gerum's avatar Philippe Gerum
Browse files

lib/tube: deprecate interface



The tube API is sp/sc only and may have other issues. We introduced
the SCQ (ring buffer) as a replacement, which is mp/mc, ABA-safe,
linearizable, lock-free and livelock-safe.

Mark the tube API as deprecated, before its removal scheduled for r29.
Signed-off-by: Philippe Gerum's avatarPhilippe Gerum <rpm@xenomai.org>
parent 6deb7e8c
......@@ -20,7 +20,7 @@
#include <evl/poll.h>
#include <evl/proxy.h>
#define __EVL__ 18 /* API version */
#define __EVL__ 19 /* API version */
#define EVL_ABI_PREREQ 26
......
......@@ -6,6 +6,8 @@
* The tube: a lighweight, lockless single-reader/single-writer FIFO
* with a base-offset addressing variant which can work over a memory
* segment shared between processes (*_rel form).
*
* CAUTION: This interface is DEPRECATED, and WILL BE REMOVED.
*/
#ifndef _EVL_TUBE_H
......@@ -18,6 +20,11 @@
#include <evl/compiler.h>
#include <evl/atomic.h>
static inline __deprecated void evl_tube_deprecated(void)
{
/* Switch to EVL ring <evl/ring.h> instead. */
}
/*
* The tricky one: pulling a canister from the tube. The noticeable
* part is how we deal with the end-of-queue situation, temporarily
......@@ -172,6 +179,7 @@
do { \
typeof((__tube)->pending.tail) __i; \
int __n; \
evl_tube_deprecated(); \
*(__tube) = (typeof(*(__tube))) \
TUBE_INITIALIZER(*(__tube)); \
for (__n = 0, __i = (typeof(__i))(__freevec); \
......@@ -323,6 +331,7 @@
({ \
struct __name *__tube = (typeof(__tube))(__mem); \
typeof(__tube->free.first[0]) *__i, *__iend; \
evl_tube_deprecated(); \
*__tube = (typeof(*__tube)) \
TUBE_INITIALIZER_REL(*__tube, __can_struct); \
__iend = (typeof(__iend))((char *)__mem + __size); \
......
/*
* SPDX-License-Identifier: MIT
*
* COMPILE-TESTING ONLY.
*/
#include <evl/tube.h>
DECLARE_EVL_CANISTER(long_canister, long);
static DECLARE_EVL_TUBE(tube_type, long_canister) tube;
static struct long_canister long_items[16];
static long build_test_tube(void)
{
int count = sizeof(long_items) / sizeof(long_items[0]);
long val;
evl_init_tube(&tube, long_items, count);
evl_send_tube(&tube, 0);
evl_receive_tube(&tube, val);
(void)val;
return (size_t)evl_get_tube_size(tube_type, count);
}
DECLARE_EVL_CANISTER_REL(int_canister, int);
DECLARE_EVL_TUBE_REL(rel_tube_type, int_canister, int);
static int build_test_tube_rel(void)
{
struct rel_tube_type *tube_rel;
size_t size;
void *mem;
int val;
size = evl_get_tube_size_rel(rel_tube_type, 100);
mem = malloc(size);
tube_rel = (struct rel_tube_type *)
evl_init_tube_rel(rel_tube_type, int_canister, mem, size);
evl_send_tube_rel(tube_rel, 0);
evl_receive_tube_rel(tube_rel, val);
return val;
}
int main(int argc, char *argv[])
{
build_test_tube();
build_test_tube_rel();
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment