File: uring.h

package info (click to toggle)
rtpengine 13.5.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,676 kB
  • sloc: ansic: 86,764; perl: 59,422; python: 3,193; sh: 1,030; makefile: 693; asm: 211
file content (62 lines) | stat: -rw-r--r-- 1,643 bytes parent folder | download
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
59
60
61
62
#ifndef _URING_H_
#define _URING_H_

#include <string.h>

#include "socket.h"

struct uring_req;

typedef void uring_req_handler_fn(struct uring_req *, int32_t res, uint32_t flags);

struct uring_req {
	uring_req_handler_fn *handler;
};

struct uring_methods {
	ssize_t (*sendmsg)(socket_t *, struct msghdr *, const endpoint_t *,
			struct sockaddr_storage *, struct uring_req *);
	unsigned int (*thread_loop)(void);
	void (*free)(struct uring_req *);
	void *(*__alloc_req)(void *, size_t);
};

extern __thread struct uring_methods uring_methods;

INLINE void uring_req_free(struct uring_req *r, int32_t res, uint32_t flags) {
	uring_methods.free(r);
}

#define uring_alloc(sv, fn) ({ \
			__typeof__(sv) __ret = uring_methods.__alloc_req((sv), sizeof(*(sv))); \
			memset(sv, 0, sizeof(*(sv))); \
			__ret->req.handler = (fn); \
			__ret; \
		})


#ifdef HAVE_LIBURING

#include "bufferpool.h"

void uring_thread_init(void);
void uring_thread_cleanup(void);

struct poller_item;
struct poller *uring_poller_new(void);
void uring_poller_free(struct poller **pp);
void uring_poller_add_waker(struct poller *p);
void uring_poller_wake(struct poller *p);
void uring_poller_poll(struct poller *);
void uring_poller_clear(struct poller *);

bool uring_poller_add_item(struct poller *p, struct poller_item *i);
bool uring_poller_del_item(struct poller *p, int fd);
void uring_poller_blocked(struct poller *p, void *fdp);
bool uring_poller_isblocked(struct poller *p, void *fdp);
void uring_poller_error(struct poller *p, void *fdp);
bool uring_poller_del_item_callback(struct poller *p, int fd, void (*callback)(void *), void *arg);

#endif

#endif