-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharing.h
41 lines (35 loc) · 1.1 KB
/
aring.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/******************************************************************
* aring.h
*
* This is the header file for all atomic ring functions.
*
* Licensed under the included terms (unlicense)
*
* D J Capelis, 2015
*****************************************************************/
#ifndef ARING_H
#define ARING_H
#include<stdatomic.h>
/*
* If your system does not include <stdatomic.h>, you can try commenting
* that line out and uncommenting the line below which attempts to
* invoke atomics routines in compilers on systems without completed
* support for C11.
*/
/* #include "compat/stdatomic.h" */
struct atomic_ring;
int aring_init(struct atomic_ring * aring, unsigned int size);
int aring_give(struct atomic_ring * aring, void * item);
int aring_take(struct atomic_ring * aring, void ** item);
unsigned int aring_query(struct atomic_ring * aring);
unsigned int aring_capacity(struct atomic_ring * aring);
int aring_free(struct atomic_ring * aring);
struct atomic_ring
{
atomic_uint items;
unsigned int size;
unsigned int head;
unsigned int tail;
void ** rb; /* ring buffer */
};
#endif /* ARING_H */