httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@hyperreal.org
Subject cvs commit: apache-2.0/src/lib/apr/mmap/unix common.c mmap.c mmap_h.h
Date Thu, 04 Nov 1999 12:33:43 GMT
dreid       99/11/04 04:33:43

  Modified:    src/lib/apr/include apr_mmap.h
               src/lib/apr/mmap/beos common.c mmap.c mmap_h.h
               src/lib/apr/mmap/unix common.c mmap.c mmap_h.h
  Log:
  This adds a new mmap function for both BeOS and unix.
  
  Also a couple of small corrections to previous code.
  
  Revision  Changes    Path
  1.3       +2 -0      apache-2.0/src/lib/apr/include/apr_mmap.h
  
  Index: apr_mmap.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_mmap.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- apr_mmap.h	1999/11/03 12:33:32	1.2
  +++ apr_mmap.h	1999/11/04 12:33:39	1.3
  @@ -73,6 +73,8 @@
   /* creation */
   ap_status_t ap_mmap_create(ap_mmap_t ** newmmap, const char *fname, ap_context_t *cntxt);
   ap_status_t ap_mmap_open_create(ap_mmap_t **newmmap, ap_file_t *file, ap_context_t *cntxt);
  +ap_status_t ap_mmap_size_create(ap_mmap_t **newmmap, ap_file_t *file, ap_size_t size,
  +                                ap_context_t *cntxt);
   
   /* destruction */
   ap_status_t ap_mmap_delete(ap_mmap_t *mmap);
  
  
  
  1.2       +0 -1      apache-2.0/src/lib/apr/mmap/beos/common.c
  
  Index: common.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/mmap/beos/common.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- common.c	1999/11/03 12:30:55	1.1
  +++ common.c	1999/11/04 12:33:40	1.2
  @@ -1,3 +1,2 @@
   #include "../unix/common.c"
   
  -
  
  
  
  1.4       +45 -2     apache-2.0/src/lib/apr/mmap/beos/mmap.c
  
  Index: mmap.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/mmap/beos/mmap.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- mmap.c	1999/11/03 12:30:55	1.3
  +++ mmap.c	1999/11/04 12:33:40	1.4
  @@ -123,7 +123,8 @@
       (*new)->size = st.st_size;
       (*new)->area = aid;
       (*new)->cntxt = cont;
  -           
  +    (*new)->statted = 1;
  +               
       /* register the cleanup... */ 
       ap_register_cleanup((*new)->cntxt, (void*)(*new), mmap_cleanup,
                ap_null_cleanup);
  @@ -145,7 +146,7 @@
       if (file->filedes == -1)
           /* there isn't a file handle so how can we mmap?? */
           return APR_EBADF;
  -    (*new) = (struct mmap_t*)ap_palloc(file->cntxt, sizeof(struct mmap_t));
  +    (*new) = (struct mmap_t*)ap_palloc(cont, sizeof(struct mmap_t));
       
       if (!file->stated) {
           /* hmmmm... we need to stat the file now */
  @@ -180,6 +181,48 @@
       (*new)->size = file->size;
       (*new)->area = aid;
       (*new)->cntxt = cont;
  +    (*new)->statted = 1;
  +    
  +    /* register the cleanup... */ 
  +    ap_register_cleanup((*new)->cntxt, (void*)(*new), mmap_cleanup,
  +             ap_null_cleanup);
  +
  +    return APR_SUCCESS;
  +}
  +
  +ap_status_t ap_mmap_size_create(ap_mmap_t **new, ap_file_t *file, ap_size_t mmapsize,
  +                                ap_context_t *cont)
  +{
  +    char *mm;
  +    area_id aid = -1;
  +    char *areaname = "apr_mmap\0";
  +    uint32 size;           
  +    
  +    if (file->buffered)
  +        return APR_EBADF;
  +    if (file->filedes == -1)
  +        return APR_EBADF;
  +    (*new) = (struct mmap_t*)ap_palloc(cont, sizeof(struct mmap_t));
  +      
  +    size = ((mmapsize -1) / B_PAGE_SIZE) + 1;
  +
  +    aid = create_area(areaname, (void*)&mm, B_ANY_ADDRESS, size * B_PAGE_SIZE, 
  +        B_FULL_LOCK, B_READ_AREA|B_WRITE_AREA);
  +    free(areaname);
  +    
  +    if (aid < B_OK) {
  +        /* we failed to get an mmap'd file... */
  +        return APR_ENOMEM;
  +    }  
  +    if (aid >= B_OK)
  +        read(file->filedes, mm, mmapsize);    
  +
  +    (*new)->filename = ap_pstrdup(cont, file->fname);
  +    (*new)->mm = mm;
  +    (*new)->size = mmapsize;
  +    (*new)->area = aid;
  +    (*new)->cntxt = cont;
  +    (*new)->statted = 0;
   
       /* register the cleanup... */ 
       ap_register_cleanup((*new)->cntxt, (void*)(*new), mmap_cleanup,
  
  
  
  1.2       +1 -0      apache-2.0/src/lib/apr/mmap/beos/mmap_h.h
  
  Index: mmap_h.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/mmap/beos/mmap_h.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mmap_h.h	1999/10/20 20:22:03	1.1
  +++ mmap_h.h	1999/11/04 12:33:40	1.2
  @@ -69,6 +69,7 @@
       area_id area;
       void *mm;
       size_t size;
  +    ap_int32_t statted;
   };
   
   ap_status_t mmap_cleanup(void *);
  
  
  
  1.2       +5 -1      apache-2.0/src/lib/apr/mmap/unix/common.c
  
  Index: common.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/mmap/unix/common.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- common.c	1999/11/03 12:30:59	1.1
  +++ common.c	1999/11/04 12:33:41	1.2
  @@ -88,6 +88,11 @@
       const ap_mmap_t *b = *(ap_mmap_t **)m2;
       ap_int32_t c;
   
  +    if (a->statted == 0 || b->statted == 0) {
  +        /* we can't do this as we have no stat info... */
  +        /* what do we return??? */
  +        return (-1);
  +    }
       c = a->sinfo.st_ino - b->sinfo.st_ino;
       if (c == 0) {
   	    return a->sinfo.st_dev - b->sinfo.st_dev;
  @@ -111,7 +116,6 @@
           return APR_EINVAL;
       
       (*addr) = mmap->mm + offset;
  -    fprintf(stderr,"ap_mmap_offset (%p, %d) ==> %p\n",mmap->mm, offset, (*addr));
       return APR_SUCCESS;
   }
   
  
  
  
  1.5       +28 -1     apache-2.0/src/lib/apr/mmap/unix/mmap.c
  
  Index: mmap.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/mmap/unix/mmap.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- mmap.c	1999/11/03 12:30:59	1.4
  +++ mmap.c	1999/11/04 12:33:42	1.5
  @@ -129,7 +129,7 @@
       if (file->filedes == -1)
           /* there isn't a file handle so how can we mmap?? */
           return APR_EBADF;
  -    (*new) = (struct mmap_t*)ap_palloc(file->cntxt, sizeof(struct mmap_t));
  +    (*new) = (struct mmap_t*)ap_palloc(cont, sizeof(struct mmap_t));
       
       if (!file->stated) {
           /* hmmmm... we need to stat the file now */
  @@ -163,6 +163,33 @@
       return APR_SUCCESS;
   }
   
  +ap_status_t ap_mmap_size_create(ap_mmap_t **new, ap_file_t *file, ap_size_t mmapsize,
  +                                ap_context_t *cont)
  +{
  +    caddr_t mm;
  +
  +    if (file->buffered)
  +        return APR_EBADF;
  +    if (file->filedes == -1)
  +        return APR_EBADF;
  +
  +    (*new) = (struct mmap_t*)ap_palloc(cont, sizeof(struct mmap_t));
  +    
  +    mm = mmap(NULL, mmapsize, PROT_READ, MAP_SHARED, file->filedes ,0);
  +    if (mm == (caddr_t)-1) {
  +        return APR_ENOMEM;
  +    }
  +
  +    (*new)->filename = ap_pstrdup(cont, file->fname);
  +    (*new)->mm = mm;
  +    (*new)->size = mmapsize;
  +    (*new)->cntxt = cont;
  +           
  +    /* register the cleanup... */
  +    ap_register_cleanup((*new)->cntxt, (void*)(*new), mmap_cleanup,
  +             ap_null_cleanup);
  +    return APR_SUCCESS;
  +}
   
   ap_status_t ap_mmap_delete(struct mmap_t *mmap)
   {
  
  
  
  1.2       +2 -1      apache-2.0/src/lib/apr/mmap/unix/mmap_h.h
  
  Index: mmap_h.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/mmap/unix/mmap_h.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mmap_h.h	1999/10/20 20:22:05	1.1
  +++ mmap_h.h	1999/11/04 12:33:42	1.2
  @@ -67,9 +67,10 @@
       struct stat sinfo;
       void *mm;
       size_t size;
  +    ap_int32_t statted;
   };
   
   ap_status_t mmap_cleanup(void *);
   
  -#endif  /* ! FILE_IO_H */
  +#endif  /* ! MMAP_H_H */
   
  
  
  

Mime
View raw message