xref: /unit/src/nxt_main.h (revision 14:556c5643cb8d)
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 
13 #include <nxt_unix.h>
14 #include <nxt_clang.h>
15 #include <nxt_types.h>
16 #include <nxt_time.h>
17 #include <nxt_process.h>
18 
19 typedef struct nxt_task_s            nxt_task_t;
20 typedef struct nxt_thread_s          nxt_thread_t;
21 #include <nxt_thread_id.h>
22 
23 typedef struct nxt_mem_pool_s        nxt_mem_pool_t;
24 #include <nxt_mem_pool.h>
25 
26 #include <nxt_errno.h>
27 #include <nxt_file.h>
28 
29 #include <nxt_random.h>
30 #include <nxt_string.h>
31 #include <nxt_utf8.h>
32 #include <nxt_file_name.h>
33 
34 typedef struct nxt_log_s             nxt_log_t;
35 #include <nxt_log.h>
36 
37 
38 #include <nxt_atomic.h>
39 #include <nxt_queue.h>
40 #include <nxt_rbtree.h>
41 #include <nxt_sprintf.h>
42 #include <nxt_parse.h>
43 
44 
45 /* TODO: remove unused */
46 
47 typedef struct nxt_fd_event_s           nxt_fd_event_t;
48 typedef struct nxt_sockaddr_s           nxt_sockaddr_t;
49 
50 
51 #include <nxt_malloc.h>
52 #include <nxt_mem_map.h>
53 #include <nxt_socket.h>
54 #include <nxt_spinlock.h>
55 #include <nxt_dyld.h>
56 
57 #include <nxt_work_queue.h>
58 
59 
60 typedef void *(*nxt_mem_proto_alloc_t)(void *pool, size_t size);
61 typedef void (*nxt_mem_proto_free_t)(void *pool, void *p);
62 
63 typedef struct {
64     nxt_mem_proto_alloc_t  alloc;
65     nxt_mem_proto_free_t   free;
66 } nxt_mem_proto_t;
67 
68 
69 #include <nxt_mem_cache_pool.h>
70 #include <nxt_mem_zone.h>
71 #include <nxt_mem_pool_cleanup.h>
72 #include <nxt_thread_time.h>
73 
74 typedef struct nxt_event_engine_s    nxt_event_engine_t;
75 #include <nxt_timer.h>
76 #include <nxt_fiber.h>
77 
78 typedef struct nxt_thread_pool_s     nxt_thread_pool_t;
79 #include <nxt_thread.h>
80 
81 #include <nxt_signal.h>
82 #if (NXT_THREADS)
83 #include <nxt_semaphore.h>
84 #endif
85 
86 #include <nxt_djb_hash.h>
87 #include <nxt_murmur_hash.h>
88 #include <nxt_lvlhsh.h>
89 #include <nxt_hash.h>
90 
91 #include <nxt_sort.h>
92 #include <nxt_array.h>
93 #include <nxt_vector.h>
94 #include <nxt_list.h>
95 
96 #include <nxt_service.h>
97 
98 typedef struct nxt_buf_s                nxt_buf_t;
99 #include <nxt_buf.h>
100 #include <nxt_buf_pool.h>
101 #include <nxt_recvbuf.h>
102 
103 typedef struct nxt_event_conn_s         nxt_event_conn_t;
104 #include <nxt_sendbuf.h>
105 
106 #include <nxt_log_moderation.h>
107 
108 #if (NXT_SSLTLS)
109 #include <nxt_ssltls.h>
110 #endif
111 
112 
113 #define                                                                       \
114 nxt_thread()                                                                  \
115     (nxt_thread_t *) nxt_thread_get_data(nxt_thread_context)
116 
117 nxt_thread_extern_data(nxt_thread_t, nxt_thread_context);
118 
119 
120 #include <nxt_thread_log.h>
121 
122 #include <nxt_fd_event.h>
123 
124 typedef struct nxt_cycle_s  nxt_cycle_t;
125 #include <nxt_port.h>
126 #if (NXT_THREADS)
127 #include <nxt_thread_pool.h>
128 #endif
129 
130 
131 typedef void (*nxt_event_conn_handler_t)(nxt_thread_t *thr,
132     nxt_event_conn_t *c);
133 #include <nxt_listen_socket.h>
134 
135 #include <nxt_event_conn.h>
136 #include <nxt_event_file.h>
137 #include <nxt_event_engine.h>
138 
139 #include <nxt_job.h>
140 #include <nxt_job_file.h>
141 #include <nxt_buf_filter.h>
142 
143 #include <nxt_job_resolve.h>
144 #include <nxt_sockaddr.h>
145 
146 #include <nxt_cache.h>
147 
148 #include <nxt_source.h>
149 typedef struct nxt_upstream_source_s  nxt_upstream_source_t;
150 
151 #include <nxt_stream_source.h>
152 #include <nxt_upstream.h>
153 #include <nxt_upstream_source.h>
154 #include <nxt_http_parse.h>
155 #include <nxt_http_source.h>
156 #include <nxt_fastcgi_source.h>
157 #include <nxt_cycle.h>
158 
159 
160 #if (NXT_LIB_UNIT_TEST)
161 #include <../test/nxt_lib_unit_test.h>
162 #else
163 #define NXT_LIB_UNIT_TEST_STATIC  static
164 #endif
165 
166 
167 /*
168  * The envp argument must be &environ if application may
169  * change its process title with nxt_process_title().
170  */
171 NXT_EXPORT nxt_int_t nxt_lib_start(const char *app, char **argv, char ***envp);
172 NXT_EXPORT void nxt_lib_stop(void);
173 
174 
175 NXT_EXPORT extern nxt_uint_t    nxt_ncpu;
176 NXT_EXPORT extern nxt_uint_t    nxt_pagesize;
177 NXT_EXPORT extern nxt_task_t    nxt_main_task;
178 NXT_EXPORT extern nxt_atomic_t  nxt_task_ident;
179 NXT_EXPORT extern nxt_random_t  nxt_random_data;
180 
181 
182 #endif /* _NXT_LIB_H_INCLUDED_ */
183