180Smax.romanov@nginx.com 280Smax.romanov@nginx.com /* 380Smax.romanov@nginx.com * Copyright (C) Max Romanov 480Smax.romanov@nginx.com * Copyright (C) NGINX, Inc. 580Smax.romanov@nginx.com */ 642Smax.romanov@nginx.com 742Smax.romanov@nginx.com #ifndef _NXT_PORT_MEMORY_H_INCLUDED_ 842Smax.romanov@nginx.com #define _NXT_PORT_MEMORY_H_INCLUDED_ 942Smax.romanov@nginx.com 1080Smax.romanov@nginx.com 1142Smax.romanov@nginx.com #define PORT_MMAP_MIN_SIZE (3 * sizeof(uint32_t)) 1242Smax.romanov@nginx.com 1342Smax.romanov@nginx.com typedef struct nxt_port_mmap_header_s nxt_port_mmap_header_t; 14365Smax.romanov@nginx.com typedef struct nxt_port_mmap_handler_s nxt_port_mmap_handler_t; 1542Smax.romanov@nginx.com 16365Smax.romanov@nginx.com void nxt_port_mmaps_destroy(nxt_port_mmaps_t *port_mmaps, nxt_bool_t free_elts); 17141Smax.romanov@nginx.com 18423Smax.romanov@nginx.com typedef struct nxt_port_mmap_tracking_s nxt_port_mmap_tracking_t; 19423Smax.romanov@nginx.com 20423Smax.romanov@nginx.com struct nxt_port_mmap_tracking_s { 21423Smax.romanov@nginx.com void *mmap_handler; 22423Smax.romanov@nginx.com nxt_atomic_t *tracking; 23423Smax.romanov@nginx.com }; 24423Smax.romanov@nginx.com 25423Smax.romanov@nginx.com nxt_int_t 26*1546Smax.romanov@nginx.com nxt_port_mmap_get_tracking(nxt_task_t *task, nxt_port_mmaps_t *mmaps, 27423Smax.romanov@nginx.com nxt_port_mmap_tracking_t *tracking, uint32_t stream); 28423Smax.romanov@nginx.com 29423Smax.romanov@nginx.com nxt_bool_t 30423Smax.romanov@nginx.com nxt_port_mmap_tracking_cancel(nxt_task_t *task, 31423Smax.romanov@nginx.com nxt_port_mmap_tracking_t *tracking, uint32_t stream); 32423Smax.romanov@nginx.com 33423Smax.romanov@nginx.com nxt_int_t 34423Smax.romanov@nginx.com nxt_port_mmap_tracking_write(uint32_t *buf, nxt_port_mmap_tracking_t *t); 35423Smax.romanov@nginx.com 36423Smax.romanov@nginx.com nxt_bool_t 37423Smax.romanov@nginx.com nxt_port_mmap_tracking_read(nxt_task_t *task, nxt_port_recv_msg_t *msg); 38423Smax.romanov@nginx.com 3942Smax.romanov@nginx.com /* 40*1546Smax.romanov@nginx.com * Allocates nxt_but_t structure from task's thread engine mem_pool, assigns 41*1546Smax.romanov@nginx.com * this buf 'mem' pointers to first available shared mem bucket(s). 'size' 42*1546Smax.romanov@nginx.com * used as a hint to acquire several successive buckets if possible. 4342Smax.romanov@nginx.com */ 4442Smax.romanov@nginx.com nxt_buf_t * 45*1546Smax.romanov@nginx.com nxt_port_mmap_get_buf(nxt_task_t *task, nxt_port_mmaps_t *mmaps, size_t size); 4642Smax.romanov@nginx.com 4780Smax.romanov@nginx.com nxt_int_t nxt_port_mmap_increase_buf(nxt_task_t *task, nxt_buf_t *b, 48206Smax.romanov@nginx.com size_t size, size_t min_size); 4980Smax.romanov@nginx.com 50365Smax.romanov@nginx.com nxt_port_mmap_handler_t * 5142Smax.romanov@nginx.com nxt_port_incoming_port_mmap(nxt_task_t *task, nxt_process_t *process, 5242Smax.romanov@nginx.com nxt_fd_t fd); 5342Smax.romanov@nginx.com 5442Smax.romanov@nginx.com void 5542Smax.romanov@nginx.com nxt_port_mmap_write(nxt_task_t *task, nxt_port_t *port, 561125Smax.romanov@nginx.com nxt_port_send_msg_t *msg, nxt_sendbuf_coalesce_t *sb, void *mmsg_buf); 5742Smax.romanov@nginx.com 5842Smax.romanov@nginx.com void 59423Smax.romanov@nginx.com nxt_port_mmap_read(nxt_task_t *task, nxt_port_recv_msg_t *msg); 6042Smax.romanov@nginx.com 6142Smax.romanov@nginx.com enum nxt_port_method_e { 6242Smax.romanov@nginx.com NXT_PORT_METHOD_ANY = 0, 6342Smax.romanov@nginx.com NXT_PORT_METHOD_PLAIN, 6442Smax.romanov@nginx.com NXT_PORT_METHOD_MMAP 6542Smax.romanov@nginx.com }; 6642Smax.romanov@nginx.com 6742Smax.romanov@nginx.com typedef enum nxt_port_method_e nxt_port_method_t; 6842Smax.romanov@nginx.com 6942Smax.romanov@nginx.com nxt_port_method_t 7042Smax.romanov@nginx.com nxt_port_mmap_get_method(nxt_task_t *task, nxt_port_t *port, nxt_buf_t *b); 7142Smax.romanov@nginx.com 721526Smax.romanov@nginx.com nxt_int_t nxt_shm_open(nxt_task_t *task, size_t size); 7380Smax.romanov@nginx.com 7442Smax.romanov@nginx.com #endif /* _NXT_PORT_MEMORY_H_INCLUDED_ */ 75