apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: apr/shmem/unix shm.c
Date Mon, 04 Mar 2002 16:40:58 GMT
trawick     02/03/04 08:40:58

  Modified:    shmem/unix shm.c
  Log:
  preserve the proper alignment when we use the start of the shared
  memory for metadata
  
  Revision  Changes    Path
  1.15      +13 -6     apr/shmem/unix/shm.c
  
  Index: shm.c
  ===================================================================
  RCS file: /home/cvs/apr/shmem/unix/shm.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- shm.c	5 Feb 2002 04:32:52 -0000	1.14
  +++ shm.c	4 Mar 2002 16:40:58 -0000	1.15
  @@ -161,7 +161,8 @@
           }
           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 @@
           /* 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 @@
           /* 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 @@
           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 @@
           /* 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 @@
               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 @@
           }
   
           /* 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);
  
  
  

Mime
View raw message