xref: /unit/src/nxt_main.h (revision 2714:0bbeaf388f1f)
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_NAME                     "Unit"
15 #define NXT_SERVER                   NXT_NAME "/" NXT_VERSION
16 
17 typedef struct nxt_port_s            nxt_port_t;
18 typedef struct nxt_task_s            nxt_task_t;
19 typedef struct nxt_port_recv_msg_s   nxt_port_recv_msg_t;
20 typedef void (*nxt_port_handler_t)(nxt_task_t *task, nxt_port_recv_msg_t *msg);
21 typedef struct nxt_port_handlers_s   nxt_port_handlers_t;
22 typedef struct nxt_sig_event_s       nxt_sig_event_t;
23 typedef struct nxt_runtime_s         nxt_runtime_t;
24 
25 typedef struct nxt_thread_s          nxt_thread_t;
26 typedef struct nxt_event_engine_s    nxt_event_engine_t;
27 typedef struct nxt_log_s             nxt_log_t;
28 typedef struct nxt_thread_pool_s     nxt_thread_pool_t;
29 
30 typedef void (*nxt_work_handler_t)(nxt_task_t *task, void *obj, void *data);
31 
32 #include <nxt_unix.h>
33 #include <nxt_clang.h>
34 #include <nxt_types.h>
35 #include <nxt_time.h>
36 #include <nxt_mp.h>
37 #include <nxt_array.h>
38 
39 typedef uint16_t                     nxt_port_id_t;
40 
41 #include <nxt_queue.h>
42 
43 #include <nxt_thread_id.h>
44 
45 #include <nxt_errno.h>
46 #include <nxt_file.h>
47 
48 #include <nxt_random.h>
49 #include <nxt_string.h>
50 #include <nxt_lvlhsh.h>
51 #include <nxt_atomic.h>
52 #include <nxt_spinlock.h>
53 #include <nxt_work_queue.h>
54 #include <nxt_log.h>
55 #include <nxt_thread_time.h>
56 #include <nxt_rbtree.h>
57 #include <nxt_timer.h>
58 #include <nxt_fiber.h>
59 #include <nxt_thread.h>
60 #include <nxt_process_type.h>
61 #include <nxt_capability.h>
62 #include <nxt_credential.h>
63 #include <nxt_fs_mount.h>
64 #include <nxt_fs.h>
65 #include <nxt_process.h>
66 #include <nxt_utf8.h>
67 #include <nxt_file_name.h>
68 
69 #include <nxt_sprintf.h>
70 #include <nxt_parse.h>
71 
72 typedef struct nxt_tstr_state_s  nxt_tstr_state_t;
73 #include <nxt_var.h>
74 #include <nxt_tstr.h>
75 
76 
77 /* TODO: remove unused */
78 
79 typedef struct nxt_fd_event_s           nxt_fd_event_t;
80 typedef struct nxt_sockaddr_s           nxt_sockaddr_t;
81 
82 
83 #include <nxt_malloc.h>
84 #include <nxt_mem_map.h>
85 #include <nxt_socket.h>
86 #include <nxt_dyld.h>
87 
88 
89 typedef void *(*nxt_mem_proto_alloc_t)(void *pool, size_t size);
90 typedef void (*nxt_mem_proto_free_t)(void *pool, void *p);
91 
92 typedef struct {
93     nxt_mem_proto_alloc_t  alloc;
94     nxt_mem_proto_free_t   free;
95 } nxt_mem_proto_t;
96 
97 
98 #include <nxt_mem_zone.h>
99 #include <nxt_signal.h>
100 #include <nxt_semaphore.h>
101 
102 #include <nxt_djb_hash.h>
103 #include <nxt_murmur_hash.h>
104 #include <nxt_hash.h>
105 
106 #include <nxt_sort.h>
107 #include <nxt_vector.h>
108 #include <nxt_list.h>
109 
110 #include <nxt_service.h>
111 
112 typedef struct nxt_buf_s                nxt_buf_t;
113 #include <nxt_buf.h>
114 #include <nxt_buf_pool.h>
115 #include <nxt_recvbuf.h>
116 
117 typedef struct nxt_conn_s               nxt_conn_t;
118 #include <nxt_sendbuf.h>
119 
120 #include <nxt_log_moderation.h>
121 
122 #if (NXT_TLS)
123 #include <nxt_tls.h>
124 #endif
125 
126 
127 #define nxt_thread()                                                          \
128     (nxt_thread_t *) nxt_thread_get_data(nxt_thread_context)
129 
130 nxt_thread_extern_data(nxt_thread_t, nxt_thread_context);
131 
132 
133 #include <nxt_thread_log.h>
134 
135 #include <nxt_fd_event.h>
136 #include <nxt_file_event.h>
137 
138 #include <nxt_port.h>
139 #include <nxt_port_memory.h>
140 #include <nxt_port_rpc.h>
141 #include <nxt_thread_pool.h>
142 
143 
144 typedef void (*nxt_event_conn_handler_t)(nxt_thread_t *thr, nxt_conn_t *c);
145 #include <nxt_listen_socket.h>
146 
147 #include <nxt_conn.h>
148 #include <nxt_event_engine.h>
149 
150 #include <nxt_job.h>
151 
152 #include <nxt_sockaddr.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