xref: /unit/src/nxt_port_memory.h (revision 42)
1*42Smax.romanov@nginx.com 
2*42Smax.romanov@nginx.com #ifndef _NXT_PORT_MEMORY_H_INCLUDED_
3*42Smax.romanov@nginx.com #define _NXT_PORT_MEMORY_H_INCLUDED_
4*42Smax.romanov@nginx.com 
5*42Smax.romanov@nginx.com #define PORT_MMAP_MIN_SIZE (3 * sizeof(uint32_t))
6*42Smax.romanov@nginx.com 
7*42Smax.romanov@nginx.com typedef struct nxt_port_mmap_header_s nxt_port_mmap_header_t;
8*42Smax.romanov@nginx.com 
9*42Smax.romanov@nginx.com void
10*42Smax.romanov@nginx.com nxt_port_mmap_destroy(nxt_port_mmap_t *port_mmap);
11*42Smax.romanov@nginx.com 
12*42Smax.romanov@nginx.com /*
13*42Smax.romanov@nginx.com  * Allocates nxt_but_t structure from port's mem_pool, assigns this buf 'mem'
14*42Smax.romanov@nginx.com  * pointers to first available shared mem bucket(s). 'size' used as a hint to
15*42Smax.romanov@nginx.com  * acquire several successive buckets if possible.
16*42Smax.romanov@nginx.com  *
17*42Smax.romanov@nginx.com  * This function assumes that current thread operates the 'port' exclusively.
18*42Smax.romanov@nginx.com  */
19*42Smax.romanov@nginx.com nxt_buf_t *
20*42Smax.romanov@nginx.com nxt_port_mmap_get_buf(nxt_task_t *task, nxt_port_t *port, size_t size);
21*42Smax.romanov@nginx.com 
22*42Smax.romanov@nginx.com nxt_port_mmap_t *
23*42Smax.romanov@nginx.com nxt_port_incoming_port_mmap(nxt_task_t *task, nxt_process_t *process,
24*42Smax.romanov@nginx.com     nxt_fd_t fd);
25*42Smax.romanov@nginx.com 
26*42Smax.romanov@nginx.com void
27*42Smax.romanov@nginx.com nxt_port_mmap_write(nxt_task_t *task, nxt_port_t *port,
28*42Smax.romanov@nginx.com     nxt_port_send_msg_t *msg, nxt_sendbuf_coalesce_t *sb);
29*42Smax.romanov@nginx.com 
30*42Smax.romanov@nginx.com nxt_inline void
31*42Smax.romanov@nginx.com nxt_port_mmap_completion(nxt_task_t *task, nxt_work_queue_t *wq, nxt_buf_t *b) {
32*42Smax.romanov@nginx.com     nxt_work_queue_add(wq, b->completion_handler, task, b, b->parent);
33*42Smax.romanov@nginx.com }
34*42Smax.romanov@nginx.com 
35*42Smax.romanov@nginx.com void
36*42Smax.romanov@nginx.com nxt_port_mmap_read(nxt_task_t *task, nxt_port_t *port,
37*42Smax.romanov@nginx.com     nxt_port_recv_msg_t *msg, size_t size);
38*42Smax.romanov@nginx.com 
39*42Smax.romanov@nginx.com enum nxt_port_method_e {
40*42Smax.romanov@nginx.com     NXT_PORT_METHOD_ANY = 0,
41*42Smax.romanov@nginx.com     NXT_PORT_METHOD_PLAIN,
42*42Smax.romanov@nginx.com     NXT_PORT_METHOD_MMAP
43*42Smax.romanov@nginx.com };
44*42Smax.romanov@nginx.com 
45*42Smax.romanov@nginx.com typedef enum nxt_port_method_e nxt_port_method_t;
46*42Smax.romanov@nginx.com 
47*42Smax.romanov@nginx.com nxt_port_method_t
48*42Smax.romanov@nginx.com nxt_port_mmap_get_method(nxt_task_t *task, nxt_port_t *port, nxt_buf_t *b);
49*42Smax.romanov@nginx.com 
50*42Smax.romanov@nginx.com #endif /* _NXT_PORT_MEMORY_H_INCLUDED_ */
51