GME  13
apr_mmap.h
Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef APR_MMAP_H
00018 #define APR_MMAP_H
00019 
00025 #include "apr.h"
00026 #include "apr_pools.h"
00027 #include "apr_errno.h"
00028 #include "apr_ring.h"
00029 #include "apr_file_io.h"        /* for apr_file_t */
00030 
00031 #ifdef BEOS
00032 #include <kernel/OS.h>
00033 #endif
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif /* __cplusplus */
00038 
00046 #define APR_MMAP_READ    1
00047 
00048 #define APR_MMAP_WRITE   2
00049 
00051 typedef struct apr_mmap_t            apr_mmap_t;
00052 
00062 struct apr_mmap_t {
00064     apr_pool_t *cntxt;
00065 #ifdef BEOS
00066 
00067     area_id area;
00068 #endif
00069 #ifdef WIN32
00070 
00071     HANDLE mhandle;
00073     void *mv;
00075     apr_off_t  pstart;
00076     apr_size_t psize;
00077     apr_off_t  poffset;
00078 #endif
00079 
00080     void *mm;
00082     apr_size_t size;
00085     APR_RING_ENTRY(apr_mmap_t) link;
00086 };
00087 
00088 #if APR_HAS_MMAP || defined(DOXYGEN)
00089 
00095 #ifdef MMAP_THRESHOLD
00096 #  define APR_MMAP_THRESHOLD              MMAP_THRESHOLD
00097 #else
00098 #  ifdef SUNOS4
00099 #    define APR_MMAP_THRESHOLD            (8*1024)
00100 #  else
00101 #    define APR_MMAP_THRESHOLD            1
00102 #  endif /* SUNOS4 */
00103 #endif /* MMAP_THRESHOLD */
00104 
00108 #ifdef MMAP_LIMIT
00109 #  define APR_MMAP_LIMIT                  MMAP_LIMIT
00110 #else
00111 #  define APR_MMAP_LIMIT                  (4*1024*1024)
00112 #endif /* MMAP_LIMIT */
00113 
00115 #define APR_MMAP_CANDIDATE(filelength) \
00116     ((filelength >= APR_MMAP_THRESHOLD) && (filelength < APR_MMAP_LIMIT))
00117 
00118 /*   Function definitions */
00119 
00133 APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **newmmap, 
00134                                           apr_file_t *file, apr_off_t offset,
00135                                           apr_size_t size, apr_int32_t flag,
00136                                           apr_pool_t *cntxt);
00137 
00144 APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap,
00145                                        apr_mmap_t *old_mmap,
00146                                        apr_pool_t *p);
00147 
00152 APR_DECLARE(apr_status_t) apr_mmap_delete(apr_mmap_t *mm);
00153 
00160 APR_DECLARE(apr_status_t) apr_mmap_offset(void **addr, apr_mmap_t *mm, 
00161                                           apr_off_t offset);
00162 
00163 #endif /* APR_HAS_MMAP */
00164 
00167 #ifdef __cplusplus
00168 }
00169 #endif
00170 
00171 #endif  /* ! APR_MMAP_H */