xref: /unit/src/nxt_main.h (revision 320)
10Sigor@sysoev.ru 
20Sigor@sysoev.ru /*
30Sigor@sysoev.ru  * Copyright (C) Igor Sysoev
40Sigor@sysoev.ru  * Copyright (C) NGINX, Inc.
50Sigor@sysoev.ru  */
60Sigor@sysoev.ru 
70Sigor@sysoev.ru #ifndef _NXT_LIB_H_INCLUDED_
80Sigor@sysoev.ru #define _NXT_LIB_H_INCLUDED_
90Sigor@sysoev.ru 
100Sigor@sysoev.ru 
110Sigor@sysoev.ru #include <nxt_auto_config.h>
120Sigor@sysoev.ru 
13221Sigor@sysoev.ru 
14221Sigor@sysoev.ru #define NXT_VERSION                  "0.1"
15258Sigor@sysoev.ru #define NXT_VERNUM                   0x00000001
16221Sigor@sysoev.ru 
17221Sigor@sysoev.ru 
18164Smax.romanov@nginx.com typedef struct nxt_port_s            nxt_port_t;
19164Smax.romanov@nginx.com typedef struct nxt_task_s            nxt_task_t;
20164Smax.romanov@nginx.com typedef struct nxt_port_recv_msg_s   nxt_port_recv_msg_t;
21164Smax.romanov@nginx.com typedef void (*nxt_port_handler_t)(nxt_task_t *task, nxt_port_recv_msg_t *msg);
22*320Smax.romanov@nginx.com typedef struct nxt_port_handlers_s   nxt_port_handlers_t;
23164Smax.romanov@nginx.com typedef struct nxt_sig_event_s       nxt_sig_event_t;
24164Smax.romanov@nginx.com typedef struct nxt_runtime_s         nxt_runtime_t;
25164Smax.romanov@nginx.com 
26164Smax.romanov@nginx.com typedef struct nxt_thread_s          nxt_thread_t;
27164Smax.romanov@nginx.com typedef struct nxt_event_engine_s    nxt_event_engine_t;
28164Smax.romanov@nginx.com typedef struct nxt_log_s             nxt_log_t;
29164Smax.romanov@nginx.com typedef struct nxt_thread_pool_s     nxt_thread_pool_t;
30164Smax.romanov@nginx.com 
31164Smax.romanov@nginx.com typedef void (*nxt_work_handler_t)(nxt_task_t *task, void *obj, void *data);
32164Smax.romanov@nginx.com 
330Sigor@sysoev.ru #include <nxt_unix.h>
340Sigor@sysoev.ru #include <nxt_clang.h>
350Sigor@sysoev.ru #include <nxt_types.h>
360Sigor@sysoev.ru #include <nxt_time.h>
3765Sigor@sysoev.ru #include <nxt_mp.h>
3820Sigor@sysoev.ru #include <nxt_array.h>
3920Sigor@sysoev.ru 
4042Smax.romanov@nginx.com typedef uint16_t                     nxt_port_id_t;
4120Sigor@sysoev.ru 
4242Smax.romanov@nginx.com #include <nxt_queue.h>
430Sigor@sysoev.ru 
440Sigor@sysoev.ru #include <nxt_thread_id.h>
450Sigor@sysoev.ru 
460Sigor@sysoev.ru #include <nxt_errno.h>
470Sigor@sysoev.ru #include <nxt_file.h>
480Sigor@sysoev.ru 
490Sigor@sysoev.ru #include <nxt_random.h>
500Sigor@sysoev.ru #include <nxt_string.h>
5188Smax.romanov@nginx.com #include <nxt_lvlhsh.h>
5290Smax.romanov@nginx.com #include <nxt_atomic.h>
5390Smax.romanov@nginx.com #include <nxt_spinlock.h>
5490Smax.romanov@nginx.com #include <nxt_work_queue.h>
5590Smax.romanov@nginx.com #include <nxt_log.h>
5690Smax.romanov@nginx.com #include <nxt_thread_time.h>
5790Smax.romanov@nginx.com #include <nxt_rbtree.h>
5890Smax.romanov@nginx.com #include <nxt_timer.h>
5990Smax.romanov@nginx.com #include <nxt_fiber.h>
6090Smax.romanov@nginx.com #include <nxt_thread.h>
61245Smax.romanov@nginx.com #include <nxt_process_type.h>
6288Smax.romanov@nginx.com #include <nxt_process.h>
630Sigor@sysoev.ru #include <nxt_utf8.h>
640Sigor@sysoev.ru #include <nxt_file_name.h>
650Sigor@sysoev.ru 
660Sigor@sysoev.ru #include <nxt_sprintf.h>
670Sigor@sysoev.ru #include <nxt_parse.h>
680Sigor@sysoev.ru 
690Sigor@sysoev.ru 
700Sigor@sysoev.ru /* TODO: remove unused */
710Sigor@sysoev.ru 
7212Sigor@sysoev.ru typedef struct nxt_fd_event_s           nxt_fd_event_t;
730Sigor@sysoev.ru typedef struct nxt_sockaddr_s           nxt_sockaddr_t;
740Sigor@sysoev.ru 
750Sigor@sysoev.ru 
760Sigor@sysoev.ru #include <nxt_malloc.h>
770Sigor@sysoev.ru #include <nxt_mem_map.h>
780Sigor@sysoev.ru #include <nxt_socket.h>
790Sigor@sysoev.ru #include <nxt_dyld.h>
800Sigor@sysoev.ru 
810Sigor@sysoev.ru 
820Sigor@sysoev.ru typedef void *(*nxt_mem_proto_alloc_t)(void *pool, size_t size);
830Sigor@sysoev.ru typedef void (*nxt_mem_proto_free_t)(void *pool, void *p);
840Sigor@sysoev.ru 
850Sigor@sysoev.ru typedef struct {
860Sigor@sysoev.ru     nxt_mem_proto_alloc_t  alloc;
870Sigor@sysoev.ru     nxt_mem_proto_free_t   free;
880Sigor@sysoev.ru } nxt_mem_proto_t;
890Sigor@sysoev.ru 
900Sigor@sysoev.ru 
910Sigor@sysoev.ru #include <nxt_mem_zone.h>
920Sigor@sysoev.ru #include <nxt_signal.h>
930Sigor@sysoev.ru #include <nxt_semaphore.h>
940Sigor@sysoev.ru 
950Sigor@sysoev.ru #include <nxt_djb_hash.h>
960Sigor@sysoev.ru #include <nxt_murmur_hash.h>
970Sigor@sysoev.ru #include <nxt_hash.h>
980Sigor@sysoev.ru 
990Sigor@sysoev.ru #include <nxt_sort.h>
1000Sigor@sysoev.ru #include <nxt_vector.h>
1010Sigor@sysoev.ru #include <nxt_list.h>
1020Sigor@sysoev.ru 
1030Sigor@sysoev.ru #include <nxt_service.h>
1040Sigor@sysoev.ru 
1050Sigor@sysoev.ru typedef struct nxt_buf_s                nxt_buf_t;
10642Smax.romanov@nginx.com typedef struct nxt_port_mmap_s          nxt_port_mmap_t;
1070Sigor@sysoev.ru #include <nxt_buf.h>
1080Sigor@sysoev.ru #include <nxt_buf_pool.h>
1090Sigor@sysoev.ru #include <nxt_recvbuf.h>
1100Sigor@sysoev.ru 
11162Sigor@sysoev.ru typedef struct nxt_conn_s               nxt_conn_t;
1120Sigor@sysoev.ru #include <nxt_sendbuf.h>
1130Sigor@sysoev.ru 
1140Sigor@sysoev.ru #include <nxt_log_moderation.h>
1150Sigor@sysoev.ru 
1160Sigor@sysoev.ru #if (NXT_SSLTLS)
1170Sigor@sysoev.ru #include <nxt_ssltls.h>
1180Sigor@sysoev.ru #endif
1190Sigor@sysoev.ru 
1200Sigor@sysoev.ru 
12120Sigor@sysoev.ru #define nxt_thread()                                                          \
1220Sigor@sysoev.ru     (nxt_thread_t *) nxt_thread_get_data(nxt_thread_context)
1230Sigor@sysoev.ru 
1240Sigor@sysoev.ru nxt_thread_extern_data(nxt_thread_t, nxt_thread_context);
1250Sigor@sysoev.ru 
1260Sigor@sysoev.ru 
1270Sigor@sysoev.ru #include <nxt_thread_log.h>
1280Sigor@sysoev.ru 
12912Sigor@sysoev.ru #include <nxt_fd_event.h>
13062Sigor@sysoev.ru #include <nxt_file_event.h>
1310Sigor@sysoev.ru 
13214Sigor@sysoev.ru #include <nxt_port.h>
13342Smax.romanov@nginx.com #include <nxt_port_memory.h>
134190Smax.romanov@nginx.com #include <nxt_port_rpc.h>
1350Sigor@sysoev.ru #include <nxt_thread_pool.h>
1360Sigor@sysoev.ru 
1370Sigor@sysoev.ru 
13862Sigor@sysoev.ru typedef void (*nxt_event_conn_handler_t)(nxt_thread_t *thr, nxt_conn_t *c);
1390Sigor@sysoev.ru #include <nxt_listen_socket.h>
1400Sigor@sysoev.ru 
14162Sigor@sysoev.ru #include <nxt_conn.h>
1420Sigor@sysoev.ru #include <nxt_event_engine.h>
1430Sigor@sysoev.ru 
1440Sigor@sysoev.ru #include <nxt_job.h>
1450Sigor@sysoev.ru #include <nxt_job_file.h>
1460Sigor@sysoev.ru #include <nxt_buf_filter.h>
1470Sigor@sysoev.ru 
1480Sigor@sysoev.ru #include <nxt_job_resolve.h>
1490Sigor@sysoev.ru #include <nxt_sockaddr.h>
1500Sigor@sysoev.ru 
1510Sigor@sysoev.ru #include <nxt_cache.h>
1520Sigor@sysoev.ru 
1530Sigor@sysoev.ru #include <nxt_source.h>
1540Sigor@sysoev.ru typedef struct nxt_upstream_source_s  nxt_upstream_source_t;
1550Sigor@sysoev.ru 
15616Svbart@nginx.com #include <nxt_http_parse.h>
1570Sigor@sysoev.ru #include <nxt_stream_source.h>
1580Sigor@sysoev.ru #include <nxt_upstream.h>
1590Sigor@sysoev.ru #include <nxt_upstream_source.h>
1600Sigor@sysoev.ru #include <nxt_http_source.h>
1610Sigor@sysoev.ru #include <nxt_fastcgi_source.h>
16220Sigor@sysoev.ru #include <nxt_runtime.h>
16375Smax.romanov@nginx.com #include <nxt_port_hash.h>
1640Sigor@sysoev.ru 
1650Sigor@sysoev.ru 
1660Sigor@sysoev.ru /*
1670Sigor@sysoev.ru  * The envp argument must be &environ if application may
1680Sigor@sysoev.ru  * change its process title with nxt_process_title().
1690Sigor@sysoev.ru  */
1700Sigor@sysoev.ru NXT_EXPORT nxt_int_t nxt_lib_start(const char *app, char **argv, char ***envp);
1710Sigor@sysoev.ru NXT_EXPORT void nxt_lib_stop(void);
1720Sigor@sysoev.ru 
1730Sigor@sysoev.ru 
1740Sigor@sysoev.ru NXT_EXPORT extern nxt_uint_t    nxt_ncpu;
1750Sigor@sysoev.ru NXT_EXPORT extern nxt_uint_t    nxt_pagesize;
1761Sigor@sysoev.ru NXT_EXPORT extern nxt_task_t    nxt_main_task;
1771Sigor@sysoev.ru NXT_EXPORT extern nxt_atomic_t  nxt_task_ident;
1780Sigor@sysoev.ru 
1790Sigor@sysoev.ru 
1800Sigor@sysoev.ru #endif /* _NXT_LIB_H_INCLUDED_ */
181