xref: /unit/src/nxt_port_memory.h (revision 2126:8542c8141a13)
1 
2 /*
3  * Copyright (C) Max Romanov
4  * Copyright (C) NGINX, Inc.
5  */
6 
7 #ifndef _NXT_PORT_MEMORY_H_INCLUDED_
8 #define _NXT_PORT_MEMORY_H_INCLUDED_
9 
10 
11 #define PORT_MMAP_MIN_SIZE (3 * sizeof(uint32_t))
12 
13 typedef struct nxt_port_mmap_header_s nxt_port_mmap_header_t;
14 typedef struct nxt_port_mmap_handler_s nxt_port_mmap_handler_t;
15 
16 void nxt_port_mmaps_destroy(nxt_port_mmaps_t *port_mmaps, nxt_bool_t free_elts);
17 
18 /*
19  * Allocates nxt_but_t structure from task's thread engine mem_pool, assigns
20  * this buf 'mem' pointers to first available shared mem bucket(s). 'size'
21  * used as a hint to acquire several successive buckets if possible.
22  */
23 nxt_buf_t *
24 nxt_port_mmap_get_buf(nxt_task_t *task, nxt_port_mmaps_t *mmaps, size_t size);
25 
26 nxt_int_t nxt_port_mmap_increase_buf(nxt_task_t *task, nxt_buf_t *b,
27     size_t size, size_t min_size);
28 
29 nxt_port_mmap_handler_t *
30 nxt_port_incoming_port_mmap(nxt_task_t *task, nxt_process_t *process,
31     nxt_fd_t fd);
32 
33 void
34 nxt_port_mmap_write(nxt_task_t *task, nxt_port_t *port,
35     nxt_port_send_msg_t *msg, nxt_sendbuf_coalesce_t *sb, void *mmsg_buf);
36 
37 void
38 nxt_port_mmap_read(nxt_task_t *task, nxt_port_recv_msg_t *msg);
39 
40 enum nxt_port_method_e {
41     NXT_PORT_METHOD_ANY = 0,
42     NXT_PORT_METHOD_PLAIN,
43     NXT_PORT_METHOD_MMAP
44 };
45 
46 typedef enum nxt_port_method_e nxt_port_method_t;
47 
48 nxt_port_method_t
49 nxt_port_mmap_get_method(nxt_task_t *task, nxt_port_t *port, nxt_buf_t *b);
50 
51 nxt_int_t nxt_shm_open(nxt_task_t *task, size_t size);
52 
53 void nxt_process_broadcast_shm_ack(nxt_task_t *task, nxt_process_t *process);
54 
55 #endif /* _NXT_PORT_MEMORY_H_INCLUDED_ */
56