Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ngx_buf.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright (C) Igor Sysoev
4  * Copyright (C) Nginx, Inc.
5  */
6 
7 
8 #ifndef _NGX_BUF_H_INCLUDED_
9 #define _NGX_BUF_H_INCLUDED_
10 
11 
12 #include <ngx_config.h>
13 #include <ngx_core.h>
14 
15 
16 typedef void * ngx_buf_tag_t;
17 
18 typedef struct ngx_buf_s ngx_buf_t;
19 
20 struct ngx_buf_s {
21  u_char *pos;
22  u_char *last;
23  off_t file_pos;
24  off_t file_last;
25 
26  u_char *start; /* start of buffer */
27  u_char *end; /* end of buffer */
31 
32 
33  /* the buf's content could be changed */
34  unsigned temporary:1;
35 
36  /*
37  * the buf's content is in a memory cache or in a read only memory
38  * and must not be changed
39  */
40  unsigned memory:1;
41 
42  /* the buf's content is mmap()ed and must not be changed */
43  unsigned mmap:1;
44 
45  unsigned recycled:1;
46  unsigned in_file:1;
47  unsigned flush:1;
48  unsigned sync:1;
49  unsigned last_buf:1;
50  unsigned last_in_chain:1;
51 
52  unsigned last_shadow:1;
53  unsigned temp_file:1;
54 
55  /* STUB */ int num;
56 };
57 
58 
59 struct ngx_chain_s {
62 };
63 
64 
65 typedef struct {
67  size_t size;
68 } ngx_bufs_t;
69 
70 
72 
74 
75 #if (NGX_HAVE_FILE_AIO)
76 typedef void (*ngx_output_chain_aio_pt)(ngx_output_chain_ctx_t *ctx,
77  ngx_file_t *file);
78 #endif
79 
85 
86  unsigned sendfile:1;
87  unsigned directio:1;
88 #if (NGX_HAVE_ALIGNED_DIRECTIO)
89  unsigned unaligned:1;
90 #endif
91  unsigned need_in_memory:1;
92  unsigned need_in_temp:1;
93 #if (NGX_HAVE_FILE_AIO)
94  unsigned aio:1;
95 
96  ngx_output_chain_aio_pt aio_handler;
97 #endif
98 
99  off_t alignment;
100 
105 
107  void *filter_ctx;
108 };
109 
110 
111 typedef struct {
116  off_t limit;
118 
119 
120 #define NGX_CHAIN_ERROR (ngx_chain_t *) NGX_ERROR
121 
122 
123 #define ngx_buf_in_memory(b) (b->temporary || b->memory || b->mmap)
124 #define ngx_buf_in_memory_only(b) (ngx_buf_in_memory(b) && !b->in_file)
125 
126 #define ngx_buf_special(b) \
127  ((b->flush || b->last_buf || b->sync) \
128  && !ngx_buf_in_memory(b) && !b->in_file)
129 
130 #define ngx_buf_sync_only(b) \
131  (b->sync \
132  && !ngx_buf_in_memory(b) && !b->in_file && !b->flush && !b->last_buf)
133 
134 #define ngx_buf_size(b) \
135  (ngx_buf_in_memory(b) ? (off_t) (b->last - b->pos): \
136  (b->file_last - b->file_pos))
137 
138 ngx_buf_t *ngx_create_temp_buf(ngx_pool_t *pool, size_t size);
140 
141 
142 #define ngx_alloc_buf(pool) ngx_palloc(pool, sizeof(ngx_buf_t))
143 #define ngx_calloc_buf(pool) ngx_pcalloc(pool, sizeof(ngx_buf_t))
144 
146 #define ngx_free_chain(pool, cl) \
147  cl->next = pool->chain; \
148  pool->chain = cl
149 
150 
151 
153 ngx_int_t ngx_chain_writer(void *ctx, ngx_chain_t *in);
154 
156  ngx_chain_t *in);
159  ngx_chain_t **busy, ngx_chain_t **out, ngx_buf_tag_t tag);
160 
161 
162 #endif /* _NGX_BUF_H_INCLUDED_ */