ring.h
1/*
2 * Copyright 2007-2024 Carnegie Mellon University
3 * See license information in LICENSE.txt.
4 */
5/*
6 * ring.c
7 * General ring array implementation
8 *
9 * ------------------------------------------------------------------------
10 * Authors: Brian Trammell
11 * ------------------------------------------------------------------------
12 * @DISTRIBUTION_STATEMENT_BEGIN@
13 * YAF 2.16
14 *
15 * Copyright 2024 Carnegie Mellon University.
16 *
17 * NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE ENGINEERING
18 * INSTITUTE MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON
19 * UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
20 * AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR
21 * PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF
22 * THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF
23 * ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT
24 * INFRINGEMENT.
25 *
26 * Licensed under a GNU GPL 2.0-style license, please see LICENSE.txt or
27 * contact permission@sei.cmu.edu for full terms.
28 *
29 * [DISTRIBUTION STATEMENT A] This material has been approved for public
30 * release and unlimited distribution. Please see Copyright notice for
31 * non-US Government use and distribution.
32 *
33 * This Software includes and/or makes use of Third-Party Software each
34 * subject to its own license.
35 *
36 * DM24-1063
37 * @DISTRIBUTION_STATEMENT_END@
38 * ------------------------------------------------------------------------
39 */
40
41#ifndef _YAF_RING_H_
42#define _YAF_RING_H_
43#include <yaf/autoinc.h>
44
45struct rgaRing_st;
46typedef struct rgaRing_st rgaRing_t;
47
48rgaRing_t *
49rgaAlloc(
50 size_t elt_sz,
51 size_t cap);
52
53void
54rgaFree(
55 rgaRing_t *ring);
56
57uint8_t *
58rgaNextHead(
59 rgaRing_t *ring);
60
61void
62rgaRewindHead(
63 rgaRing_t *ring);
64
65uint8_t *
66rgaNextTail(
67 rgaRing_t *ring);
68
69size_t
70rgaCount(
71 rgaRing_t *ring);
72
73size_t
74rgaPeak(
75 rgaRing_t *ring);
76
77#if YAF_RING_THREAD
78
79rgaRing_t *
80rgaAllocThreaded(
81 size_t elt_sz,
82 size_t cap);
83
84uint8_t *
85rgaWaitHead(
86 rgaRing_t *ring);
87
88void
89rgaReleaseHead(
90 rgaRing_t *ring,
91 size_t rsv);
92
93uint8_t *
94rgaWaitTail(
95 rgaRing_t *ring);
96
97void
98rgaReleaseTail(
99 rgaRing_t *ring,
100 size_t rsv);
101
102void
103rgaSetInterrupt(
104 rgaRing_t *ring);
105
106void
107rgaClearInterrupt(
108 rgaRing_t *ring);
109
110#endif /* if YAF_RING_THREAD */
111#endif /* ifndef _YAF_RING_H_ */