00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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"
00030
00031 #ifdef BEOS
00032 #include <kernel/OS.h>
00033 #endif
00034
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
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
00106 #endif
00107
00111 #ifdef MMAP_LIMIT
00112 # define APR_MMAP_LIMIT MMAP_LIMIT
00113 #else
00114 # define APR_MMAP_LIMIT (4*1024*1024)
00115 #endif
00116
00118 #define APR_MMAP_CANDIDATE(filelength) \
00119 ((filelength >= APR_MMAP_THRESHOLD) && (filelength < APR_MMAP_LIMIT))
00120
00121
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
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
00186
00189 #ifdef __cplusplus
00190 }
00191 #endif
00192
00193 #endif