nxt_buf.h (65:10688b89aa16) nxt_buf.h (122:d18727e877c6)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#ifndef _NXT_BUF_H_INCLUDED_
8#define _NXT_BUF_H_INCLUDED_

--- 62 unchanged lines hidden (view full) ---

71
72 /*
73 * The next link, flags, and nxt_buf_mem_t should
74 * reside together to improve cache locality.
75 */
76 nxt_buf_t *next;
77
78 uint32_t retain;
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#ifndef _NXT_BUF_H_INCLUDED_
8#define _NXT_BUF_H_INCLUDED_

--- 62 unchanged lines hidden (view full) ---

71
72 /*
73 * The next link, flags, and nxt_buf_mem_t should
74 * reside together to improve cache locality.
75 */
76 nxt_buf_t *next;
77
78 uint32_t retain;
79 /*
80 * Used by nxt_mem_cache_free() to return buffer
81 * in appropriate memory pool cache.
82 */
83 uint8_t size;
84
85 uint8_t is_file; /* 1 bit */
86
87 uint16_t is_mmap:1;
88 uint16_t is_port_mmap:1;
89
90 uint16_t is_sync:1;
91 uint16_t is_nobuf:1;
92 uint16_t is_flush:1;
93 uint16_t is_last:1;
94 uint16_t is_port_mmap_sent:1;
79
80 uint8_t is_file; /* 1 bit */
81
82 uint16_t is_mmap:1;
83 uint16_t is_port_mmap:1;
84
85 uint16_t is_sync:1;
86 uint16_t is_nobuf:1;
87 uint16_t is_flush:1;
88 uint16_t is_last:1;
89 uint16_t is_port_mmap_sent:1;
90 uint16_t is_ts:1;
95
96 nxt_buf_mem_t mem;
97
98 /* The file and mmap parts are not allocated by nxt_buf_mem_alloc(). */
99 nxt_file_t *file;
100 nxt_off_t file_pos;
101 nxt_off_t file_end;
102

--- 137 unchanged lines hidden (view full) ---

240nxt_buf_used_size(b) \
241 (nxt_buf_is_file(b) ? (b)->file_end - (b)->file_pos: \
242 nxt_buf_mem_used_size(&(b)->mem))
243
244
245NXT_EXPORT void nxt_buf_mem_init(nxt_buf_t *b, void *start, size_t size);
246NXT_EXPORT nxt_buf_t *nxt_buf_mem_alloc(nxt_mp_t *mp, size_t size,
247 nxt_uint_t flags);
91
92 nxt_buf_mem_t mem;
93
94 /* The file and mmap parts are not allocated by nxt_buf_mem_alloc(). */
95 nxt_file_t *file;
96 nxt_off_t file_pos;
97 nxt_off_t file_end;
98

--- 137 unchanged lines hidden (view full) ---

236nxt_buf_used_size(b) \
237 (nxt_buf_is_file(b) ? (b)->file_end - (b)->file_pos: \
238 nxt_buf_mem_used_size(&(b)->mem))
239
240
241NXT_EXPORT void nxt_buf_mem_init(nxt_buf_t *b, void *start, size_t size);
242NXT_EXPORT nxt_buf_t *nxt_buf_mem_alloc(nxt_mp_t *mp, size_t size,
243 nxt_uint_t flags);
244NXT_EXPORT nxt_buf_t *nxt_buf_mem_ts_alloc(nxt_task_t *task, nxt_mp_t *mp,
245 size_t size);
248NXT_EXPORT nxt_buf_t *nxt_buf_file_alloc(nxt_mp_t *mp, size_t size,
249 nxt_uint_t flags);
250NXT_EXPORT nxt_buf_t *nxt_buf_mmap_alloc(nxt_mp_t *mp, size_t size);
251NXT_EXPORT nxt_buf_t *nxt_buf_sync_alloc(nxt_mp_t *mp, nxt_uint_t flags);
252
246NXT_EXPORT nxt_buf_t *nxt_buf_file_alloc(nxt_mp_t *mp, size_t size,
247 nxt_uint_t flags);
248NXT_EXPORT nxt_buf_t *nxt_buf_mmap_alloc(nxt_mp_t *mp, size_t size);
249NXT_EXPORT nxt_buf_t *nxt_buf_sync_alloc(nxt_mp_t *mp, nxt_uint_t flags);
250
251NXT_EXPORT nxt_int_t nxt_buf_ts_handle(nxt_task_t *task, void *obj, void *data);
253
254#define \
255nxt_buf_free(mp, b) \
256 nxt_mp_free((mp), (b))
257
258
259NXT_EXPORT void nxt_buf_chain_add(nxt_buf_t **head, nxt_buf_t *in);
260NXT_EXPORT size_t nxt_buf_chain_length(nxt_buf_t *b);
261
262
263#endif /* _NXT_BUF_H_INCLIDED_ */
252
253#define \
254nxt_buf_free(mp, b) \
255 nxt_mp_free((mp), (b))
256
257
258NXT_EXPORT void nxt_buf_chain_add(nxt_buf_t **head, nxt_buf_t *in);
259NXT_EXPORT size_t nxt_buf_chain_length(nxt_buf_t *b);
260
261
262#endif /* _NXT_BUF_H_INCLIDED_ */