Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
apr_mmap.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef APR_MMAP_H
18 #define APR_MMAP_H
19 
25 #include "apr.h"
26 #include "apr_pools.h"
27 #include "apr_errno.h"
28 #include "apr_ring.h"
29 #include "apr_file_io.h" /* for apr_file_t */
30 
31 #ifdef BEOS
32 #include <kernel/OS.h>
33 #endif
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
38 
46 #define APR_MMAP_READ 1
47 
48 #define APR_MMAP_WRITE 2
49 
51 typedef struct apr_mmap_t apr_mmap_t;
52 
62 struct apr_mmap_t {
65 #ifdef BEOS
66 
67  area_id area;
68 #endif
69 #ifdef WIN32
70 
71  HANDLE mhandle;
73  void *mv;
75  apr_off_t pstart;
76  apr_size_t psize;
77  apr_off_t poffset;
78 #endif
79 
80  void *mm;
86 };
87 
88 #if APR_HAS_MMAP || defined(DOXYGEN)
89 
95 #ifdef MMAP_THRESHOLD
96 # define APR_MMAP_THRESHOLD MMAP_THRESHOLD
97 #else
98 # ifdef SUNOS4
99 # define APR_MMAP_THRESHOLD (8*1024)
100 # else
101 # define APR_MMAP_THRESHOLD 1
102 # endif /* SUNOS4 */
103 #endif /* MMAP_THRESHOLD */
104 
108 #ifdef MMAP_LIMIT
109 # define APR_MMAP_LIMIT MMAP_LIMIT
110 #else
111 # define APR_MMAP_LIMIT (4*1024*1024)
112 #endif /* MMAP_LIMIT */
113 
115 #define APR_MMAP_CANDIDATE(filelength) \
116  ((filelength >= APR_MMAP_THRESHOLD) && (filelength < APR_MMAP_LIMIT))
117 
118 /* Function definitions */
119 
134  apr_file_t *file, apr_off_t offset,
136  apr_pool_t *cntxt);
137 
145  apr_mmap_t *old_mmap,
146  apr_pool_t *p);
147 
153 
161  apr_off_t offset);
162 
163 #endif /* APR_HAS_MMAP */
164 
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 #endif /* ! APR_MMAP_H */
size_t apr_size_t
Definition: apr.h:375
Definition: apr_arch_file_io.h:107
apr_size_t size
Definition: apr_mmap.h:82
APR File I/O Handling.
void * mm
Definition: apr_mmap.h:80
Definition: apr_mmap.h:62
APR memory allocation.
apr_status_t apr_mmap_delete(apr_mmap_t *mm)
APR_RING_ENTRY(apr_mmap_t) link
APR Error Codes.
APR Platform Definitions.
apr_pool_t * p
apr_pool_t * cntxt
Definition: apr_mmap.h:64
apr_status_t apr_mmap_dup(apr_mmap_t **new_mmap, apr_mmap_t *old_mmap, apr_pool_t *p)
#define APR_DECLARE(x)
Definition: macros.h:6
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
apr_status_t apr_mmap_create(apr_mmap_t **newmmap, apr_file_t *file, apr_off_t offset, apr_size_t size, apr_int32_t flag, apr_pool_t *cntxt)
int apr_status_t
Definition: apr_errno.h:44
off_t apr_off_t
Definition: apr.h:377
apr_status_t apr_mmap_offset(void **addr, apr_mmap_t *mm, apr_off_t offset)
APR Rings.
int apr_int32_t
Definition: apr.h:333