WAND Trace processing  4.0.5
sliding_window.h
1 /*
2  *
3  * Copyright (c) 2007-2016 The University of Waikato, Hamilton, New Zealand.
4  * All rights reserved.
5  *
6  * This file is part of libtrace.
7  *
8  * This code has been developed by the University of Waikato WAND
9  * research group. For further information please see http://www.wand.net.nz/
10  *
11  * libtrace is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * libtrace is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  *
24  *
25  */
26 #include <stdint.h>
27 #include <stddef.h>
28 
29 #ifndef LIBTRACE_SLIDING_WINDOW_H
30 #define LIBTRACE_SLIDING_WINDOW_H
31 
32 #define LIBTRACE_SLIDING_WINDOW_BLOCKING 0
33 #define LIBTRACE_SLIDING_WINDOW_SPINNING 1
34 
35 // All of start, elements and end must be accessed in the listed order
36 // if LIBTRACE_RINGBUFFER_SPINNING is to work.
37 typedef struct libtrace_slidingwindow {
38  volatile size_t start;
39  size_t size;
40  volatile uint64_t start_number;
41  void *volatile*elements;
43 
44 void libtrace_slidingwindow_init(libtrace_slidingwindow_t * sw, size_t size, uint64_t start_number);
45 void libtrace_zero_slidingwindow(libtrace_slidingwindow_t * sw);
46 void libtrace_slidingwindow_destroy(libtrace_slidingwindow_t * sw);
47 
48 /*
49 int libtrace_slidingwindow_is_empty(const libtrace_slidingwindow_t * sw);
50 int libtrace_slidingwindow_is_full(const libtrace_slidingwindow_t * sw);
51 */
52 
53 /* void libtrace_slidingwindow_write(libtrace_slidingwindow_t * sw, uint64_t number, void* value); */
54 int libtrace_slidingwindow_try_write(libtrace_slidingwindow_t * sw, uint64_t number, void* value);
55 
56 /*void* libtrace_slidingwindow_read(libtrace_slidingwindow_t *sw);*/
57 int libtrace_slidingwindow_try_read(libtrace_slidingwindow_t *sw, void ** value, uint64_t *number);
58 
59 uint64_t libtrace_slidingwindow_read_ready(libtrace_slidingwindow_t *sw);
60 /*
61 void libtrace_slidingwindow_swrite(libtrace_slidingwindow_t * sw, void* value);
62 int libtrace_slidingwindow_try_swrite(libtrace_slidingwindow_t * sw, void* value);
63 int libtrace_slidingwindow_try_swrite_bl(libtrace_slidingwindow_t * sw, void* value);
64 */
65 /*
66 void * libtrace_slidingwindow_sread(libtrace_slidingwindow_t *sw);
67 int libtrace_slidingwindow_try_sread(libtrace_slidingwindow_t *sw, void ** value);
68 int libtrace_slidingwindow_try_sread_bl(libtrace_slidingwindow_t *sw, void ** value);
69 */
70 #endif
Definition: sliding_window.h:37