diff options
author | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2002-03-04 16:40:58 +0000 |
---|---|---|
committer | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2002-03-04 16:40:58 +0000 |
commit | f07f7d2ec51222d1f4b2e87c28525a972a433fee (patch) | |
tree | ca8f5c1f76df7941d9cacb652bcd26b57d6b3f61 /shmem | |
parent | a52a206ce1be075d0fc95634135d301bef66bc02 (diff) | |
download | libapr-f07f7d2ec51222d1f4b2e87c28525a972a433fee.tar.gz |
preserve the proper alignment when we use the start of the shared
memory for metadata
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63078 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'shmem')
-rw-r--r-- | shmem/unix/shm.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/shmem/unix/shm.c b/shmem/unix/shm.c index 54310a8b7..37a1f1f3b 100644 --- a/shmem/unix/shm.c +++ b/shmem/unix/shm.c @@ -161,7 +161,8 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, } new_m->pool = pool; new_m->reqsize = reqsize; - new_m->realsize = reqsize + sizeof(apr_size_t); /* room for metadata */ + new_m->realsize = reqsize + + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); /* room for metadata */ new_m->filename = NULL; #if APR_USE_SHMEM_MMAP_ZERO @@ -189,7 +190,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, /* store the real size in the metadata */ *(apr_size_t*)(new_m->base) = new_m->realsize; /* metadata isn't usable */ - new_m->usable = (char *)new_m->base + sizeof(apr_size_t); + new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, apr_pool_cleanup_null); @@ -206,7 +207,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, /* store the real size in the metadata */ *(apr_size_t*)(new_m->base) = new_m->realsize; /* metadata isn't usable */ - new_m->usable = (char *)new_m->base + sizeof(apr_size_t); + new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, apr_pool_cleanup_null); @@ -274,7 +275,8 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, new_m->filename = apr_pstrdup(pool, filename); #if APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM - new_m->realsize = reqsize + sizeof(apr_size_t); /* room for metadata */ + new_m->realsize = reqsize + + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); /* room for metadata */ /* FIXME: Ignore error for now. * * status = apr_file_remove(file, pool);*/ status = APR_SUCCESS; @@ -345,7 +347,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, /* store the real size in the metadata */ *(apr_size_t*)(new_m->base) = new_m->realsize; /* metadata isn't usable */ - new_m->usable = (char *)new_m->base + sizeof(apr_size_t); + new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, apr_pool_cleanup_null); @@ -482,6 +484,11 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, return status; } +/* + XXX use APR_ALIGN_DEFAULT() somewhere here? + XXX do we need to seek() prior to the mmap()? +*/ + nbytes = sizeof(new_m->realsize); status = apr_file_read(file, (void *)&(new_m->realsize), &nbytes); @@ -508,7 +515,7 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, } /* metadata isn't part of the usable segment */ - new_m->usable = (char *)new_m->base + sizeof(apr_size_t); + new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_attach, apr_pool_cleanup_null); |