ring.h
1 /*
2  ** ring.c
3  ** General ring array implementation
4  **
5  ** ------------------------------------------------------------------------
6  ** Copyright (C) 2007-2015 Carnegie Mellon University. All Rights Reserved.
7  ** ------------------------------------------------------------------------
8  ** Authors: Brian Trammell
9  ** ------------------------------------------------------------------------
10  ** @OPENSOURCE_HEADER_START@
11  ** Use of the YAF system and related source code is subject to the terms
12  ** of the following licenses:
13  **
14  ** GNU Public License (GPL) Rights pursuant to Version 2, June 1991
15  ** Government Purpose License Rights (GPLR) pursuant to DFARS 252.227.7013
16  **
17  ** NO WARRANTY
18  **
19  ** ANY INFORMATION, MATERIALS, SERVICES, INTELLECTUAL PROPERTY OR OTHER
20  ** PROPERTY OR RIGHTS GRANTED OR PROVIDED BY CARNEGIE MELLON UNIVERSITY
21  ** PURSUANT TO THIS LICENSE (HEREINAFTER THE "DELIVERABLES") ARE ON AN
22  ** "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY
23  ** KIND, EITHER EXPRESS OR IMPLIED AS TO ANY MATTER INCLUDING, BUT NOT
24  ** LIMITED TO, WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE,
25  ** MERCHANTABILITY, INFORMATIONAL CONTENT, NONINFRINGEMENT, OR ERROR-FREE
26  ** OPERATION. CARNEGIE MELLON UNIVERSITY SHALL NOT BE LIABLE FOR INDIRECT,
27  ** SPECIAL OR CONSEQUENTIAL DAMAGES, SUCH AS LOSS OF PROFITS OR INABILITY
28  ** TO USE SAID INTELLECTUAL PROPERTY, UNDER THIS LICENSE, REGARDLESS OF
29  ** WHETHER SUCH PARTY WAS AWARE OF THE POSSIBILITY OF SUCH DAMAGES.
30  ** LICENSEE AGREES THAT IT WILL NOT MAKE ANY WARRANTY ON BEHALF OF
31  ** CARNEGIE MELLON UNIVERSITY, EXPRESS OR IMPLIED, TO ANY PERSON
32  ** CONCERNING THE APPLICATION OF OR THE RESULTS TO BE OBTAINED WITH THE
33  ** DELIVERABLES UNDER THIS LICENSE.
34  **
35  ** Licensee hereby agrees to defend, indemnify, and hold harmless Carnegie
36  ** Mellon University, its trustees, officers, employees, and agents from
37  ** all claims or demands made against them (and any related losses,
38  ** expenses, or attorney's fees) arising out of, or relating to Licensee's
39  ** and/or its sub licensees' negligent use or willful misuse of or
40  ** negligent conduct or willful misconduct regarding the Software,
41  ** facilities, or other rights or assistance granted by Carnegie Mellon
42  ** University under this License, including, but not limited to, any
43  ** claims of product liability, personal injury, death, damage to
44  ** property, or violation of any laws or regulations.
45  **
46  ** Carnegie Mellon University Software Engineering Institute authored
47  ** documents are sponsored by the U.S. Department of Defense under
48  ** Contract FA8721-05-C-0003. Carnegie Mellon University retains
49  ** copyrights in all material produced under this contract. The U.S.
50  ** Government retains a non-exclusive, royalty-free license to publish or
51  ** reproduce these documents, or allow others to do so, for U.S.
52  ** Government purposes only pursuant to the copyright license under the
53  ** contract clause at 252.227.7013.
54  **
55  ** @OPENSOURCE_HEADER_END@
56  ** ------------------------------------------------------------------------
57  */
58 
59 /* idem hack */
60 #ifndef _YAF_RING_H_
61 #define _YAF_RING_H_
62 #include <yaf/autoinc.h>
63 
64 struct rgaRing_st;
65 typedef struct rgaRing_st rgaRing_t;
66 
67 rgaRing_t *rgaAlloc(
68  size_t elt_sz,
69  size_t cap);
70 
71 void rgaFree(
72  rgaRing_t *ring);
73 
74 uint8_t *rgaNextHead(
75  rgaRing_t *ring);
76 
77 void rgaRewindHead(
78  rgaRing_t *ring);
79 
80 uint8_t *rgaNextTail(
81  rgaRing_t *ring);
82 
83 size_t rgaCount(
84  rgaRing_t *ring);
85 
86 size_t rgaPeak(
87  rgaRing_t *ring);
88 
89 #if YAF_RING_THREAD
90 
91 rgaRing_t *rgaAllocThreaded(
92  size_t elt_sz,
93  size_t cap);
94 
95 uint8_t *rgaWaitHead(
96  rgaRing_t *ring);
97 
98 void rgaReleaseHead(
99  rgaRing_t *ring,
100  size_t rsv);
101 
102 uint8_t *rgaWaitTail(
103  rgaRing_t *ring);
104 
105 void rgaReleaseTail(
106  rgaRing_t *ring,
107  size_t rsv);
108 
109 void rgaSetInterrupt(
110  rgaRing_t *ring);
111 
112 void rgaClearInterrupt(
113  rgaRing_t *ring);
114 
115 #endif
116 
117 /* end idem */
118 #endif