Apache2
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 #if defined(BEOS)
66 
67  area_id area;
68 #elif defined(WIN32)
69 
70  HANDLE mhandle;
72  void *mv;
73 #else
75 #endif
76 
77  void *mm;
83 };
84 
85 #if APR_HAS_MMAP || defined(DOXYGEN)
86 
92 #ifdef MMAP_THRESHOLD
93 # define APR_MMAP_THRESHOLD MMAP_THRESHOLD
94 #else
95 # ifdef SUNOS4
96 # define APR_MMAP_THRESHOLD (8*1024)
97 # else
98 # define APR_MMAP_THRESHOLD 1
99 # endif /* SUNOS4 */
100 #endif /* MMAP_THRESHOLD */
101 
105 #ifdef MMAP_LIMIT
106 # define APR_MMAP_LIMIT MMAP_LIMIT
107 #else
108 # define APR_MMAP_LIMIT (4*1024*1024)
109 #endif /* MMAP_LIMIT */
110 
112 #define APR_MMAP_CANDIDATE(filelength) \
113  ((filelength >= APR_MMAP_THRESHOLD) && (filelength < APR_MMAP_LIMIT))
114 
115 /* Function definitions */
116 
131  apr_file_t *file, apr_off_t offset,
132  apr_size_t size, apr_int32_t flag,
133  apr_pool_t *cntxt);
134 
142  apr_mmap_t *old_mmap,
143  apr_pool_t *p);
144 
150 
158  apr_off_t offset);
159 
160 #endif /* APR_HAS_MMAP */
161 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif /* ! APR_MMAP_H */
size_t apr_size_t
Definition: apr.h:393
apr_off_t poffset
Definition: apr_mmap.h:74
Definition: apr_arch_file_io.h:107
apr_size_t size
Definition: apr_mmap.h:79
APR File I/O Handling.
void * mm
Definition: apr_mmap.h:77
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:395
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:346