xref: /unit/src/nxt_main.h (revision 2216:231b36f0062c)
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_mount.h>
63 #include <nxt_fs.h>
64 #include <nxt_process.h>
65 #include <nxt_utf8.h>
66 #include <nxt_file_name.h>
67 
68 #include <nxt_sprintf.h>
69 #include <nxt_parse.h>
70 #include <nxt_var.h>
71 
72 
73 /* TODO: remove unused */
74 
75 typedef struct nxt_fd_event_s           nxt_fd_event_t;
76 typedef struct nxt_sockaddr_s           nxt_sockaddr_t;
77 
78 
79 #include <nxt_malloc.h>
80 #include <nxt_mem_map.h>
81 #include <nxt_socket.h>
82 #include <nxt_dyld.h>
83 
84 
85 typedef void *(*nxt_mem_proto_alloc_t)(void *pool, size_t size);
86 typedef void (*nxt_mem_proto_free_t)(void *pool, void *p);
87 
88 typedef struct {
89     nxt_mem_proto_alloc_t  alloc;
90     nxt_mem_proto_free_t   free;
91 } nxt_mem_proto_t;
92 
93 
94 #include <nxt_mem_zone.h>
95 #include <nxt_signal.h>
96 #include <nxt_semaphore.h>
97 
98 #include <nxt_djb_hash.h>
99 #include <nxt_murmur_hash.h>
100 #include <nxt_hash.h>
101 
102 #include <nxt_sort.h>
103 #include <nxt_vector.h>
104 #include <nxt_list.h>
105 
106 #include <nxt_service.h>
107 
108 typedef struct nxt_buf_s                nxt_buf_t;
109 #include <nxt_buf.h>
110 #include <nxt_buf_pool.h>
111 #include <nxt_recvbuf.h>
112 
113 typedef struct nxt_conn_s               nxt_conn_t;
114 #include <nxt_sendbuf.h>
115 
116 #include <nxt_log_moderation.h>
117 
118 #if (NXT_TLS)
119 #include <nxt_tls.h>
120 #endif
121 
122 
123 #define nxt_thread()                                                          \
124     (nxt_thread_t *) nxt_thread_get_data(nxt_thread_context)
125 
126 nxt_thread_extern_data(nxt_thread_t, nxt_thread_context);
127 
128 
129 #include <nxt_thread_log.h>
130 
131 #include <nxt_fd_event.h>
132 #include <nxt_file_event.h>
133 
134 #include <nxt_port.h>
135 #include <nxt_port_memory.h>
136 #include <nxt_port_rpc.h>
137 #include <nxt_thread_pool.h>
138 
139 
140 typedef void (*nxt_event_conn_handler_t)(nxt_thread_t *thr, nxt_conn_t *c);
141 #include <nxt_listen_socket.h>
142 
143 #include <nxt_conn.h>
144 #include <nxt_event_engine.h>
145 
146 #include <nxt_job.h>
147 #include <nxt_job_file.h>
148 #include <nxt_buf_filter.h>
149 
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