xref: /unit/src/nxt_main.h (revision 1563:d32bc428f46b)
1 
2 /*
3  * Copyright (C) Igor Sysoev
4  * Copyright (C) NGINX, Inc.
5  */
6 
7 #ifndef _NXT_LIB_H_INCLUDED_
8 #define _NXT_LIB_H_INCLUDED_
9 
10 
11 #include <nxt_auto_config.h>
12 #include <nxt_version.h>
13 
14 #define NXT_SERVER                   "Unit/" NXT_VERSION
15 
16 typedef struct nxt_port_s            nxt_port_t;
17 typedef struct nxt_task_s            nxt_task_t;
18 typedef struct nxt_port_recv_msg_s   nxt_port_recv_msg_t;
19 typedef void (*nxt_port_handler_t)(nxt_task_t *task, nxt_port_recv_msg_t *msg);
20 typedef struct nxt_port_handlers_s   nxt_port_handlers_t;
21 typedef struct nxt_sig_event_s       nxt_sig_event_t;
22 typedef struct nxt_runtime_s         nxt_runtime_t;
23 
24 typedef struct nxt_thread_s          nxt_thread_t;
25 typedef struct nxt_event_engine_s    nxt_event_engine_t;
26 typedef struct nxt_log_s             nxt_log_t;
27 typedef struct nxt_thread_pool_s     nxt_thread_pool_t;
28 
29 typedef void (*nxt_work_handler_t)(nxt_task_t *task, void *obj, void *data);
30 
31 #include <nxt_unix.h>
32 #include <nxt_clang.h>
33 #include <nxt_types.h>
34 #include <nxt_time.h>
35 #include <nxt_mp.h>
36 #include <nxt_array.h>
37 
38 typedef uint16_t                     nxt_port_id_t;
39 
40 #include <nxt_queue.h>
41 
42 #include <nxt_thread_id.h>
43 
44 #include <nxt_errno.h>
45 #include <nxt_file.h>
46 
47 #include <nxt_random.h>
48 #include <nxt_string.h>
49 #include <nxt_lvlhsh.h>
50 #include <nxt_atomic.h>
51 #include <nxt_spinlock.h>
52 #include <nxt_work_queue.h>
53 #include <nxt_log.h>
54 #include <nxt_thread_time.h>
55 #include <nxt_rbtree.h>
56 #include <nxt_timer.h>
57 #include <nxt_fiber.h>
58 #include <nxt_thread.h>
59 #include <nxt_process_type.h>
60 #include <nxt_capability.h>
61 #include <nxt_credential.h>
62 #include <nxt_fs.h>
63 #include <nxt_process.h>
64 #include <nxt_utf8.h>
65 #include <nxt_file_name.h>
66 
67 #include <nxt_sprintf.h>
68 #include <nxt_parse.h>
69 #include <nxt_var.h>
70 
71 
72 /* TODO: remove unused */
73 
74 typedef struct nxt_fd_event_s           nxt_fd_event_t;
75 typedef struct nxt_sockaddr_s           nxt_sockaddr_t;
76 
77 
78 #include <nxt_malloc.h>
79 #include <nxt_mem_map.h>
80 #include <nxt_socket.h>
81 #include <nxt_dyld.h>
82 
83 
84 typedef void *(*nxt_mem_proto_alloc_t)(void *pool, size_t size);
85 typedef void (*nxt_mem_proto_free_t)(void *pool, void *p);
86 
87 typedef struct {
88     nxt_mem_proto_alloc_t  alloc;
89     nxt_mem_proto_free_t   free;
90 } nxt_mem_proto_t;
91 
92 
93 #include <nxt_mem_zone.h>
94 #include <nxt_signal.h>
95 #include <nxt_semaphore.h>
96 
97 #include <nxt_djb_hash.h>
98 #include <nxt_murmur_hash.h>
99 #include <nxt_hash.h>
100 
101 #include <nxt_sort.h>
102 #include <nxt_vector.h>
103 #include <nxt_list.h>
104 
105 #include <nxt_service.h>
106 
107 typedef struct nxt_buf_s                nxt_buf_t;
108 #include <nxt_buf.h>
109 #include <nxt_buf_pool.h>
110 #include <nxt_recvbuf.h>
111 
112 typedef struct nxt_conn_s               nxt_conn_t;
113 #include <nxt_sendbuf.h>
114 
115 #include <nxt_log_moderation.h>
116 
117 #if (NXT_TLS)
118 #include <nxt_tls.h>
119 #endif
120 
121 
122 #define nxt_thread()                                                          \
123     (nxt_thread_t *) nxt_thread_get_data(nxt_thread_context)
124 
125 nxt_thread_extern_data(nxt_thread_t, nxt_thread_context);
126 
127 
128 #include <nxt_thread_log.h>
129 
130 #include <nxt_fd_event.h>
131 #include <nxt_file_event.h>
132 
133 #include <nxt_port.h>
134 #include <nxt_port_memory.h>
135 #include <nxt_port_rpc.h>
136 #include <nxt_thread_pool.h>
137 
138 
139 typedef void (*nxt_event_conn_handler_t)(nxt_thread_t *thr, nxt_conn_t *c);
140 #include <nxt_listen_socket.h>
141 
142 #include <nxt_conn.h>
143 #include <nxt_event_engine.h>
144 
145 #include <nxt_job.h>
146 #include <nxt_job_file.h>
147 #include <nxt_buf_filter.h>
148 
149 #include <nxt_job_resolve.h>
150 #include <nxt_sockaddr.h>
151 
152 #include <nxt_cache.h>
153 
154 #include <nxt_http_parse.h>
155 #include <nxt_runtime.h>
156 #include <nxt_port_hash.h>
157 
158 
159 /*
160  * The envp argument must be &environ if application may
161  * change its process title with nxt_process_title().
162  */
163 NXT_EXPORT nxt_int_t nxt_lib_start(const char *app, char **argv, char ***envp);
164 NXT_EXPORT void nxt_lib_stop(void);
165 
166 
167 NXT_EXPORT extern nxt_uint_t    nxt_ncpu;
168 NXT_EXPORT extern nxt_uint_t    nxt_pagesize;
169 NXT_EXPORT extern nxt_task_t    nxt_main_task;
170 NXT_EXPORT extern nxt_atomic_t  nxt_task_ident;
171 
172 
173 #endif /* _NXT_LIB_H_INCLUDED_ */
174