diff options
author | Yann Ylavic <ylavic@apache.org> | 2022-06-30 14:59:10 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2022-06-30 14:59:10 +0000 |
commit | 087ec06d9707924279d0583ce66771cdc9638af2 (patch) | |
tree | ff35fd674cbc85f1909cdfb2c0f3734360984ceb /mmap | |
parent | f947836bdd6461d9a58e86bd5e93b2db5002be89 (diff) | |
download | apr-087ec06d9707924279d0583ce66771cdc9638af2.tar.gz |
Revert r1887508 and r1887497.
Per https://lists.apache.org/thread/jt7by9hhvsnpo5ztjmbq5rrpnq2n0b8v
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1902372 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'mmap')
-rw-r--r-- | mmap/unix/mmap.c | 66 |
1 files changed, 4 insertions, 62 deletions
diff --git a/mmap/unix/mmap.c b/mmap/unix/mmap.c index 95afb0754..671957096 100644 --- a/mmap/unix/mmap.c +++ b/mmap/unix/mmap.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include <assert.h> - #include "apr.h" #include "apr_private.h" #include "apr_general.h" @@ -35,9 +33,6 @@ #if APR_HAVE_STDIO_H #include <stdio.h> #endif -#if APR_HAVE_UNISTD_H -#include <unistd.h> /* for sysconf() */ -#endif #ifdef HAVE_SYS_STAT_H #include <sys/stat.h> #endif @@ -47,34 +42,6 @@ #if APR_HAS_MMAP || defined(BEOS) -#ifndef BEOS -struct mm_layout { - apr_mmap_t mm; - apr_off_t poffset; -}; - -static APR_INLINE -apr_mmap_t *alloc_with_poffset(apr_pool_t *p) -{ - struct mm_layout *layout = apr_pcalloc(p, sizeof(*layout)); - return &layout->mm; -} - -static APR_INLINE -void set_poffset(apr_mmap_t *mm, apr_off_t poffset) -{ - struct mm_layout *layout = (struct mm_layout *)mm; - layout->poffset = poffset; -} - -static APR_INLINE -apr_off_t get_poffset(apr_mmap_t *mm) -{ - struct mm_layout *layout = (struct mm_layout *)mm; - return layout->poffset; -} -#endif - static apr_status_t mmap_cleanup(void *themmap) { apr_mmap_t *mm = themmap; @@ -94,7 +61,7 @@ static apr_status_t mmap_cleanup(void *themmap) #ifdef BEOS rv = delete_area(mm->area); #else - rv = munmap((char *)mm->mm - get_poffset(mm), mm->size + get_poffset(mm)); + rv = munmap(mm->mm, mm->size); #endif mm->mm = (void *)-1; @@ -114,8 +81,6 @@ APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, area_id aid = -1; uint32 pages = 0; #else - static long psize; - apr_off_t poffset = 0; apr_int32_t native_flags = 0; #endif @@ -132,11 +97,9 @@ APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, if (file == NULL || file->filedes == -1 || file->buffered) return APR_EBADF; - + (*new) = (apr_mmap_t *)apr_pcalloc(cont, sizeof(apr_mmap_t)); + #ifdef BEOS - - *new = (apr_mmap_t *)apr_pcalloc(cont, sizeof(apr_mmap_t)); - /* XXX: mmap shouldn't really change the seek offset */ apr_file_seek(file, APR_SET, &offset); @@ -158,9 +121,7 @@ APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, read(file->filedes, mm, size); (*new)->area = aid; - #else - *new = alloc_with_poffset(cont); if (flag & APR_MMAP_WRITE) { native_flags |= PROT_WRITE; @@ -169,27 +130,13 @@ APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, native_flags |= PROT_READ; } -#if defined(_SC_PAGESIZE) - if (psize == 0) { - psize = sysconf(_SC_PAGESIZE); - /* the page size should be a power of two */ - assert(psize > 0 && (psize & (psize - 1)) == 0); - } - poffset = offset & (apr_off_t)(psize - 1); - set_poffset(*new, poffset); -#endif - - mm = mmap(NULL, size + poffset, - native_flags, MAP_SHARED, - file->filedes, offset - poffset); + mm = mmap(NULL, size, native_flags, MAP_SHARED, file->filedes, offset); if (mm == (void *)-1) { /* we failed to get an mmap'd file... */ *new = NULL; return errno; } - - mm = (char *)mm + poffset; #endif (*new)->mm = mm; @@ -207,12 +154,7 @@ APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap, apr_mmap_t *old_mmap, apr_pool_t *p) { -#ifdef BEOS *new_mmap = (apr_mmap_t *)apr_pmemdup(p, old_mmap, sizeof(apr_mmap_t)); -#else - *new_mmap = (apr_mmap_t *)apr_pmemdup(p, old_mmap, - sizeof(struct mm_layout)); -#endif (*new_mmap)->cntxt = p; APR_RING_INSERT_AFTER(old_mmap, *new_mmap, link); |