xref: /unit/src/nxt_main.h (revision 1563:d32bc428f46b)
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>
12953Salexander.borisov@nginx.com #include <nxt_version.h>
13221Sigor@sysoev.ru 
14673Svbart@nginx.com #define NXT_SERVER                   "Unit/" NXT_VERSION
15221Sigor@sysoev.ru 
16164Smax.romanov@nginx.com typedef struct nxt_port_s            nxt_port_t;
17164Smax.romanov@nginx.com typedef struct nxt_task_s            nxt_task_t;
18164Smax.romanov@nginx.com typedef struct nxt_port_recv_msg_s   nxt_port_recv_msg_t;
19164Smax.romanov@nginx.com typedef void (*nxt_port_handler_t)(nxt_task_t *task, nxt_port_recv_msg_t *msg);
20320Smax.romanov@nginx.com typedef struct nxt_port_handlers_s   nxt_port_handlers_t;
21164Smax.romanov@nginx.com typedef struct nxt_sig_event_s       nxt_sig_event_t;
22164Smax.romanov@nginx.com typedef struct nxt_runtime_s         nxt_runtime_t;
23164Smax.romanov@nginx.com 
24164Smax.romanov@nginx.com typedef struct nxt_thread_s          nxt_thread_t;
25164Smax.romanov@nginx.com typedef struct nxt_event_engine_s    nxt_event_engine_t;
26164Smax.romanov@nginx.com typedef struct nxt_log_s             nxt_log_t;
27164Smax.romanov@nginx.com typedef struct nxt_thread_pool_s     nxt_thread_pool_t;
28164Smax.romanov@nginx.com 
29164Smax.romanov@nginx.com typedef void (*nxt_work_handler_t)(nxt_task_t *task, void *obj, void *data);
30164Smax.romanov@nginx.com 
310Sigor@sysoev.ru #include <nxt_unix.h>
320Sigor@sysoev.ru #include <nxt_clang.h>
330Sigor@sysoev.ru #include <nxt_types.h>
340Sigor@sysoev.ru #include <nxt_time.h>
3565Sigor@sysoev.ru #include <nxt_mp.h>
3620Sigor@sysoev.ru #include <nxt_array.h>
3720Sigor@sysoev.ru 
3842Smax.romanov@nginx.com typedef uint16_t                     nxt_port_id_t;
3920Sigor@sysoev.ru 
4042Smax.romanov@nginx.com #include <nxt_queue.h>
410Sigor@sysoev.ru 
420Sigor@sysoev.ru #include <nxt_thread_id.h>
430Sigor@sysoev.ru 
440Sigor@sysoev.ru #include <nxt_errno.h>
450Sigor@sysoev.ru #include <nxt_file.h>
460Sigor@sysoev.ru 
470Sigor@sysoev.ru #include <nxt_random.h>
480Sigor@sysoev.ru #include <nxt_string.h>
4988Smax.romanov@nginx.com #include <nxt_lvlhsh.h>
5090Smax.romanov@nginx.com #include <nxt_atomic.h>
5190Smax.romanov@nginx.com #include <nxt_spinlock.h>
5290Smax.romanov@nginx.com #include <nxt_work_queue.h>
5390Smax.romanov@nginx.com #include <nxt_log.h>
5490Smax.romanov@nginx.com #include <nxt_thread_time.h>
5590Smax.romanov@nginx.com #include <nxt_rbtree.h>
5690Smax.romanov@nginx.com #include <nxt_timer.h>
5790Smax.romanov@nginx.com #include <nxt_fiber.h>
5890Smax.romanov@nginx.com #include <nxt_thread.h>
59245Smax.romanov@nginx.com #include <nxt_process_type.h>
601182St.nateldemoura@f5.com #include <nxt_capability.h>
611305St.nateldemoura@f5.com #include <nxt_credential.h>
621489St.nateldemoura@f5.com #include <nxt_fs.h>
6388Smax.romanov@nginx.com #include <nxt_process.h>
640Sigor@sysoev.ru #include <nxt_utf8.h>
650Sigor@sysoev.ru #include <nxt_file_name.h>
660Sigor@sysoev.ru 
670Sigor@sysoev.ru #include <nxt_sprintf.h>
680Sigor@sysoev.ru #include <nxt_parse.h>
69*1563Svbart@nginx.com #include <nxt_var.h>
700Sigor@sysoev.ru 
710Sigor@sysoev.ru 
720Sigor@sysoev.ru /* TODO: remove unused */
730Sigor@sysoev.ru 
7412Sigor@sysoev.ru typedef struct nxt_fd_event_s           nxt_fd_event_t;
750Sigor@sysoev.ru typedef struct nxt_sockaddr_s           nxt_sockaddr_t;
760Sigor@sysoev.ru 
770Sigor@sysoev.ru 
780Sigor@sysoev.ru #include <nxt_malloc.h>
790Sigor@sysoev.ru #include <nxt_mem_map.h>
800Sigor@sysoev.ru #include <nxt_socket.h>
810Sigor@sysoev.ru #include <nxt_dyld.h>
820Sigor@sysoev.ru 
830Sigor@sysoev.ru 
840Sigor@sysoev.ru typedef void *(*nxt_mem_proto_alloc_t)(void *pool, size_t size);
850Sigor@sysoev.ru typedef void (*nxt_mem_proto_free_t)(void *pool, void *p);
860Sigor@sysoev.ru 
870Sigor@sysoev.ru typedef struct {
880Sigor@sysoev.ru     nxt_mem_proto_alloc_t  alloc;
890Sigor@sysoev.ru     nxt_mem_proto_free_t   free;
900Sigor@sysoev.ru } nxt_mem_proto_t;
910Sigor@sysoev.ru 
920Sigor@sysoev.ru 
930Sigor@sysoev.ru #include <nxt_mem_zone.h>
940Sigor@sysoev.ru #include <nxt_signal.h>
950Sigor@sysoev.ru #include <nxt_semaphore.h>
960Sigor@sysoev.ru 
970Sigor@sysoev.ru #include <nxt_djb_hash.h>
980Sigor@sysoev.ru #include <nxt_murmur_hash.h>
990Sigor@sysoev.ru #include <nxt_hash.h>
1000Sigor@sysoev.ru 
1010Sigor@sysoev.ru #include <nxt_sort.h>
1020Sigor@sysoev.ru #include <nxt_vector.h>
1030Sigor@sysoev.ru #include <nxt_list.h>
1040Sigor@sysoev.ru 
1050Sigor@sysoev.ru #include <nxt_service.h>
1060Sigor@sysoev.ru 
1070Sigor@sysoev.ru typedef struct nxt_buf_s                nxt_buf_t;
1080Sigor@sysoev.ru #include <nxt_buf.h>
1090Sigor@sysoev.ru #include <nxt_buf_pool.h>
1100Sigor@sysoev.ru #include <nxt_recvbuf.h>
1110Sigor@sysoev.ru 
11262Sigor@sysoev.ru typedef struct nxt_conn_s               nxt_conn_t;
1130Sigor@sysoev.ru #include <nxt_sendbuf.h>
1140Sigor@sysoev.ru 
1150Sigor@sysoev.ru #include <nxt_log_moderation.h>
1160Sigor@sysoev.ru 
117771Sigor@sysoev.ru #if (NXT_TLS)
118771Sigor@sysoev.ru #include <nxt_tls.h>
1190Sigor@sysoev.ru #endif
1200Sigor@sysoev.ru 
1210Sigor@sysoev.ru 
12220Sigor@sysoev.ru #define nxt_thread()                                                          \
1230Sigor@sysoev.ru     (nxt_thread_t *) nxt_thread_get_data(nxt_thread_context)
1240Sigor@sysoev.ru 
1250Sigor@sysoev.ru nxt_thread_extern_data(nxt_thread_t, nxt_thread_context);
1260Sigor@sysoev.ru 
1270Sigor@sysoev.ru 
1280Sigor@sysoev.ru #include <nxt_thread_log.h>
1290Sigor@sysoev.ru 
13012Sigor@sysoev.ru #include <nxt_fd_event.h>
13162Sigor@sysoev.ru #include <nxt_file_event.h>
1320Sigor@sysoev.ru 
13314Sigor@sysoev.ru #include <nxt_port.h>
13442Smax.romanov@nginx.com #include <nxt_port_memory.h>
135190Smax.romanov@nginx.com #include <nxt_port_rpc.h>
1360Sigor@sysoev.ru #include <nxt_thread_pool.h>
1370Sigor@sysoev.ru 
1380Sigor@sysoev.ru 
13962Sigor@sysoev.ru typedef void (*nxt_event_conn_handler_t)(nxt_thread_t *thr, nxt_conn_t *c);
1400Sigor@sysoev.ru #include <nxt_listen_socket.h>
1410Sigor@sysoev.ru 
14262Sigor@sysoev.ru #include <nxt_conn.h>
1430Sigor@sysoev.ru #include <nxt_event_engine.h>
1440Sigor@sysoev.ru 
1450Sigor@sysoev.ru #include <nxt_job.h>
1460Sigor@sysoev.ru #include <nxt_job_file.h>
1470Sigor@sysoev.ru #include <nxt_buf_filter.h>
1480Sigor@sysoev.ru 
1490Sigor@sysoev.ru #include <nxt_job_resolve.h>
1500Sigor@sysoev.ru #include <nxt_sockaddr.h>
1510Sigor@sysoev.ru 
1520Sigor@sysoev.ru #include <nxt_cache.h>
1530Sigor@sysoev.ru 
15416Svbart@nginx.com #include <nxt_http_parse.h>
15520Sigor@sysoev.ru #include <nxt_runtime.h>
15675Smax.romanov@nginx.com #include <nxt_port_hash.h>
1570Sigor@sysoev.ru 
1580Sigor@sysoev.ru 
1590Sigor@sysoev.ru /*
1600Sigor@sysoev.ru  * The envp argument must be &environ if application may
1610Sigor@sysoev.ru  * change its process title with nxt_process_title().
1620Sigor@sysoev.ru  */
1630Sigor@sysoev.ru NXT_EXPORT nxt_int_t nxt_lib_start(const char *app, char **argv, char ***envp);
1640Sigor@sysoev.ru NXT_EXPORT void nxt_lib_stop(void);
1650Sigor@sysoev.ru 
1660Sigor@sysoev.ru 
1670Sigor@sysoev.ru NXT_EXPORT extern nxt_uint_t    nxt_ncpu;
1680Sigor@sysoev.ru NXT_EXPORT extern nxt_uint_t    nxt_pagesize;
1691Sigor@sysoev.ru NXT_EXPORT extern nxt_task_t    nxt_main_task;
1701Sigor@sysoev.ru NXT_EXPORT extern nxt_atomic_t  nxt_task_ident;
1710Sigor@sysoev.ru 
1720Sigor@sysoev.ru 
1730Sigor@sysoev.ru #endif /* _NXT_LIB_H_INCLUDED_ */
174