ef945cae1f59692f83fc52a8117536fb4d7625a9
[oweals/dinit.git] / src / tests / test-includes / dinit.h
1 #ifndef DINIT_H_INCLUDED
2 #define DINIT_H_INCLUDED 1
3
4 // dummy dinit.h
5
6 #include "dasynq.h"
7
8 using clock_type = dasynq::clock_type;
9 using rearm = dasynq::rearm;
10 using time_val = dasynq::time_val;
11
12 namespace bp_sys {
13     extern pid_t last_forked_pid;
14 }
15
16 class eventloop_t
17 {
18     public:
19     void get_time(time_val &tv, dasynq::clock_type clock) noexcept
20     {
21         tv = {0, 0};
22     }
23
24     class child_proc_watcher
25     {
26         public:
27         pid_t fork(eventloop_t &loop, bool reserved_child_watcher, int priority = dasynq::DEFAULT_PRIORITY)
28         {
29             bp_sys::last_forked_pid++;
30             return bp_sys::last_forked_pid;
31         }
32
33         void add_reserved(eventloop_t &eloop, pid_t child, int prio = dasynq::DEFAULT_PRIORITY) noexcept
34         {
35
36         }
37
38         void stop_watch(eventloop_t &eloop) noexcept
39         {
40
41         }
42
43         void deregister(eventloop_t &loop, pid_t pid) noexcept
44         {
45
46         }
47     };
48
49     template <typename Derived> class child_proc_watcher_impl : public child_proc_watcher
50     {
51
52     };
53
54     class fd_watcher
55     {
56         int watched_fd;
57
58         public:
59         void add_watch(eventloop_t &loop, int fd, int events, bool enable = true)
60         {
61             watched_fd = fd;
62         }
63
64         int get_watched_fd() noexcept
65         {
66             return watched_fd;
67         }
68
69         void set_enabled(eventloop_t &loop, bool enable) noexcept
70         {
71
72         }
73
74         void deregister(eventloop_t &loop) noexcept
75         {
76
77         }
78     };
79
80     template <typename Derived> class fd_watcher_impl : public fd_watcher
81     {
82
83     };
84
85     class timer
86     {
87         public:
88         void add_timer(eventloop_t &loop)
89         {
90
91         }
92
93         void arm_timer_rel(eventloop_t &loop, time_val timeout) noexcept
94         {
95
96         }
97
98         void stop_timer(eventloop_t &loop) noexcept
99         {
100
101         }
102     };
103
104     template <typename Derived> class timer_impl : public timer
105     {
106
107     };
108 };
109
110 inline void open_control_socket(bool report_ro_failure = true) noexcept
111 {
112 }
113
114 inline void setup_external_log() noexcept
115 {
116 }
117
118 extern eventloop_t event_loop;
119
120 #endif