summaryrefslogtreecommitdiff
path: root/accel-pptpd/triton/triton_p.h
blob: 7c0615f782e790fa889cc09b2c63c56434e90696 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef TRITON_P_H
#define TRITON_P_H

#include <pthread.h>
#include <sys/epoll.h>
#include <ucontext.h>

#include "triton.h"
#include "list.h"
#include "spinlock.h"
#include "mempool.h"

#define CTX_STACK_SIZE 8196

struct _triton_thread_t
{
	struct list_head entry;
	struct list_head entry2;
	pthread_t thread;
	int terminate:1;
	struct _triton_context_t *ctx;
	ucontext_t uctx;
};

struct _triton_context_t
{
	struct list_head entry;
	struct list_head entry2;
	
	spinlock_t lock;
	struct _triton_thread_t *thread;
	
	struct list_head handlers;
	struct list_head timers;
	struct list_head pending_handlers;
	struct list_head pending_timers;
	struct list_head pending_calls;

	ucontext_t uctx;

	int queued:1;
	int sleeping:1;
	int need_close:1;
	int need_free:1;
	int pending:1;

	struct triton_context_t *ud;
	void *bf_arg;
};

struct _triton_md_handler_t
{
	struct list_head entry;
	struct list_head entry2;
	struct _triton_context_t *ctx;
	struct epoll_event epoll_event;
	uint32_t trig_epoll_events;
	int pending:1;
	struct triton_md_handler_t *ud;
};

struct _triton_timer_t
{
	struct list_head entry;
	struct list_head entry2;
	struct epoll_event epoll_event;
	struct _triton_context_t *ctx;
	int fd;
	int pending:1;
	struct triton_timer_t *ud;
};

struct _triton_event_t
{
	struct list_head handlers;
};

struct _triton_ctx_call_t
{
	struct list_head entry;

	void *arg;
	void (*func)(void *);
};

int log_init(void);
int md_init();
int timer_init();
int event_init();

void md_run();
void md_terminate();
void timer_run();
void timer_terminate();
struct triton_context_t *default_ctx;
int triton_queue_ctx(struct _triton_context_t*);
void triton_thread_wakeup(struct _triton_thread_t*);
int conf_load(const char *fname);
void triton_log_error(const char *fmt,...);
void triton_log_debug(const char *fmt,...);
int load_modules(const char *name);

#endif