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     int unused;
00088     APR_RING_ENTRY(apr_mmap_t) link;
00089 };
00090 
00091 #if APR_HAS_MMAP || defined(DOXYGEN)
00092 
00098 #ifdef MMAP_THRESHOLD
00099 #  define APR_MMAP_THRESHOLD              MMAP_THRESHOLD
00100 #else
00101 #  ifdef SUNOS4
00102 #    define APR_MMAP_THRESHOLD            (8*1024)
00103 #  else
00104 #    define APR_MMAP_THRESHOLD            1
00105 #  endif /* SUNOS4 */
00106 #endif /* MMAP_THRESHOLD */
00107 
00111 #ifdef MMAP_LIMIT
00112 #  define APR_MMAP_LIMIT                  MMAP_LIMIT
00113 #else
00114 #  define APR_MMAP_LIMIT                  (4*1024*1024)
00115 #endif /* MMAP_LIMIT */
00116 
00118 #define APR_MMAP_CANDIDATE(filelength) \
00119     ((filelength >= APR_MMAP_THRESHOLD) && (filelength < APR_MMAP_LIMIT))
00120 
00121 /*   Function definitions */
00122 
00136 APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **newmmap, 
00137                                           apr_file_t *file, apr_off_t offset,
00138                                           apr_size_t size, apr_int32_t flag,
00139                                           apr_pool_t *cntxt);
00140 
00149 APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap,
00150                                        apr_mmap_t *old_mmap,
00151                                        apr_pool_t *p,
00152                                        int transfer_ownership);
00153 
00154 #if defined(DOXYGEN)
00155 
00163 APR_DECLARE(apr_status_t) apr_mmap_setaside(apr_mmap_t **new_mmap,
00164                                             apr_mmap_t *old_mmap,
00165                                             apr_pool_t *p);
00166 #else
00167 #define apr_mmap_setaside(new_mmap, old_mmap, p) apr_mmap_dup(new_mmap, old_mmap, p, 1)
00168 #endif /* DOXYGEN */
00169 
00174 APR_DECLARE(apr_status_t) apr_mmap_delete(apr_mmap_t *mm);
00175 
00182 APR_DECLARE(apr_status_t) apr_mmap_offset(void **addr, apr_mmap_t *mm, 
00183                                           apr_off_t offset);
00184 
00185 #endif /* APR_HAS_MMAP */
00186 
00189 #ifdef __cplusplus
00190 }
00191 #endif
00192 
00193 #endif  /* ! APR_MMAP_H */

Generated on Mon Nov 26 11:47:26 2007 for Apache Portable Runtime by  doxygen 1.5.2