blob: 89b00a84ce8a36a5f85715e50c554a8dc217644d (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#ifndef _QUEUE_H_
#define _QUEUE_H_
#include <stdint.h>
#include "linux_list.h"
struct queue_node {
struct list_head head;
uint32_t type;
struct queue *owner;
size_t size;
};
enum {
Q_ELEM_OBJ = 0,
Q_ELEM_CTL = 1
};
void queue_node_init(struct queue_node *n, int type);
void *queue_node_data(struct queue_node *n);
struct queue_object {
struct queue_node qnode;
char data[0];
};
struct queue_object *queue_object_new(int type, size_t size);
void queue_object_free(struct queue_object *obj);
struct evfd;
#define QUEUE_NAMELEN 16
struct queue {
unsigned int max_elems;
unsigned int num_elems;
uint32_t flags;
struct list_head head;
struct evfd *evfd;
char name[QUEUE_NAMELEN];
};
#define QUEUE_F_EVFD (1U << 0)
struct queue *queue_create(const char *name,
int max_objects, unsigned int flags);
void queue_destroy(struct queue *b);
unsigned int queue_len(const struct queue *b);
int queue_add(struct queue *b, struct queue_node *n);
int queue_del(struct queue_node *n);
struct queue_node *queue_del_head(struct queue *b);
int queue_in(struct queue *b, struct queue_node *n);
void queue_iterate(struct queue *b,
const void *data,
int (*iterate)(struct queue_node *n, const void *data2));
int queue_get_eventfd(struct queue *b);
#endif
|