xref: /unit/src/nxt_main.h (revision 1489:4a3ec07f4b19)
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 
70 
71 /* TODO: remove unused */
72 
73 typedef struct nxt_fd_event_s           nxt_fd_event_t;
74 typedef struct nxt_sockaddr_s           nxt_sockaddr_t;
75 
76 
77 #include <nxt_malloc.h>
78 #include <nxt_mem_map.h>
79 #include <nxt_socket.h>
80 #include <nxt_dyld.h>
81 
82 
83 typedef void *(*nxt_mem_proto_alloc_t)(void *pool, size_t size);
84 typedef void (*nxt_mem_proto_free_t)(void *pool, void *p);
85 
86 typedef struct {
87     nxt_mem_proto_alloc_t  alloc;
88     nxt_mem_proto_free_t   free;
89 } nxt_mem_proto_t;
90 
91 
92 #include <nxt_mem_zone.h>
93 #include <nxt_signal.h>
94 #include <nxt_semaphore.h>
95 
96 #include <nxt_djb_hash.h>
97 #include <nxt_murmur_hash.h>
98 #include <nxt_hash.h>
99 
100 #include <nxt_sort.h>
101 #include <nxt_vector.h>
102 #include <nxt_list.h>
103 
104 #include <nxt_service.h>
105 
106 typedef struct nxt_buf_s                nxt_buf_t;
107 #include <nxt_buf.h>
108 #include <nxt_buf_pool.h>
109 #include <nxt_recvbuf.h>
110 
111 typedef struct nxt_conn_s               nxt_conn_t;
112 #include <nxt_sendbuf.h>
113 
114 #include <nxt_log_moderation.h>
115 
116 #if (NXT_TLS)
117 #include <nxt_tls.h>
118 #endif
119 
120 
121 #define nxt_thread()                                                          \
122     (nxt_thread_t *) nxt_thread_get_data(nxt_thread_context)
123 
124 nxt_thread_extern_data(nxt_thread_t, nxt_thread_context);
125 
126 
127 #include <nxt_thread_log.h>
128 
129 #include <nxt_fd_event.h>
130 #include <nxt_file_event.h>
131 
132 #include <nxt_port.h>
133 #include <nxt_port_memory.h>
134 #include <nxt_port_rpc.h>
135 #include <nxt_thread_pool.h>
136 
137 
138 typedef void (*nxt_event_conn_handler_t)(nxt_thread_t *thr, nxt_conn_t *c);
139 #include <nxt_listen_socket.h>
140 
141 #include <nxt_conn.h>
142 #include <nxt_event_engine.h>
143 
144 #include <nxt_job.h>
145 #include <nxt_job_file.h>
146 #include <nxt_buf_filter.h>
147 
148 #include <nxt_job_resolve.h>
149 #include <nxt_sockaddr.h>
150 
151 #include <nxt_cache.h>
152 
153 #include <nxt_http_parse.h>
154 #include <nxt_runtime.h>
155 #include <nxt_port_hash.h>
156 
157 
158 /*
159  * The envp argument must be &environ if application may
160  * change its process title with nxt_process_title().
161  */
162 NXT_EXPORT nxt_int_t nxt_lib_start(const char *app, char **argv, char ***envp);
163 NXT_EXPORT void nxt_lib_stop(void);
164 
165 
166 NXT_EXPORT extern nxt_uint_t    nxt_ncpu;
167 NXT_EXPORT extern nxt_uint_t    nxt_pagesize;
168 NXT_EXPORT extern nxt_task_t    nxt_main_task;
169 NXT_EXPORT extern nxt_atomic_t  nxt_task_ident;
170 
171 
172 #endif /* _NXT_LIB_H_INCLUDED_ */
173