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 Sat, 13 Nov 1999 00:07:26 GMT
dreid       99/11/12 16:07:26

  Modified:    src/lib/apr aclocal.m4 configure.in
               src/lib/apr/include apr_mmap.h
               src/lib/apr/mmap/beos mmap.c mmap_h.h
               src/lib/apr/mmap/unix common.c mmap.c mmap_h.h
  Log:
  hange the way that we test for the size of ssize_t, using code suggested by
  Ralf after I found that the test failed on FreeBSD.
  
  Update the mmap code to use a much simpler API than previously.  I'll
  add documentation as well as support for this in http_core.c over the
  weekend.
  
  Revision  Changes    Path
  1.6       +27 -1     apache-2.0/src/lib/apr/aclocal.m4
  
  Index: aclocal.m4
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/aclocal.m4,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- aclocal.m4	1999/11/10 18:27:02	1.5
  +++ aclocal.m4	1999/11/13 00:07:04	1.6
  @@ -133,6 +133,32 @@
   ])dnl
   fi
   rm -fr conftest*])
  -
  +dnl A variant of AC_CHECK_SIZEOF which allows the checking of
  +dnl sizes of non-builtin types
  +dnl AC_CHECK_SIZEOF_EXTENDED(INCLUDES, TYPE [, CROSS_SIZE])
  +AC_DEFUN(AC_CHECK_SIZEOF_EXTENDED,
  +[changequote(<<,>>)dnl
  +dnl The name to #define
  +define(<<AC_TYPE_NAME>>, translit(sizeof_$2, [a-z *], [A-Z_P]))dnl
  +dnl The cache variable
  +define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$2, [ *],[<p>]))dnl
  +changequote([, ])dnl
  +AC_MSG_CHECKING(size of $2)
  +AC_CACHE_VAL(AC_CV_NAME,
  +[AC_TRY_RUN([#include <stdio.h>
  +$1
  +main()
  +{
  +  FILE *f=fopen("conftestval","w");
  +  if (!f) exit(1);
  +  fprintf(f, "%d\n", sizeof($2));
  +  exit(0);
  +}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$3],,,
  +AC_CV_NAME=$3))])dnl
  +AC_MSG_RESULT($AC_CV_NAME)
  +AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
  +undefine([AC_TYPE_NAME])dnl
  +undefine([AC_CV_NAME])dnl
  +])
   
   
  
  
  
  1.25      +1 -12     apache-2.0/src/lib/apr/configure.in
  
  Index: configure.in
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/configure.in,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- configure.in	1999/11/10 13:40:51	1.24
  +++ configure.in	1999/11/13 00:07:05	1.25
  @@ -57,18 +57,7 @@
   AC_CHECK_SIZEOF(long double, 12)
   AC_CHECK_SIZEOF(long long, 8)
   
  -MY_TRY_RUN([
  -#include <sys/types.h> 
  -#include <stdlib.h> 
  -#include <stdio.h>
  -
  -int main() {
  -    return(sizeof(ssize_t));
  -} 
  -],
  -AC_DEFINE(SIZEOF_SSIZE_T, 4), 
  -AC_DEFINE_UNQUOTED(SIZEOF_SSIZE_T, $?),
  -AC_DEFINE(SIZEOF_SSIZE_T, 4))
  +AC_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], ssize_t, 8)
   
   # Use /bin/sh if it exists, otherwise go looking for sh in the path
   if test ".$SH" = . -a -f /bin/sh; then
  
  
  
  1.4       +3 -9      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- apr_mmap.h	1999/11/04 12:33:39	1.3
  +++ apr_mmap.h	1999/11/13 00:07:12	1.4
  @@ -71,19 +71,13 @@
   /*   Function definitions */
   
   /* 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);
  +ap_status_t ap_mmap_create(ap_mmap_t ** newmmap, ap_file_t *file, ap_off_t offset,
  +                 ap_size_t size, ap_context_t *cntxt);
   
   /* destruction */
   ap_status_t ap_mmap_delete(ap_mmap_t *mmap);
   
  -/* These are designed to be used in qsort, bsearch etc */
  -ap_int32_t ap_mmap_inode_compare(const void *m1, const void *m2);
  -ap_int32_t ap_mmap_filename_compare(const void *m1, const void *m2);
  -
  -ap_status_t ap_mmap_offset(void **addr, ap_mmap_t *mmap, ap_size_t offset);
  +ap_status_t ap_mmap_offset(void **addr, ap_mmap_t *mmap, ap_off_t offset);
   
   #ifdef __cplusplus
   }
  
  
  
  1.5       +13 -126   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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- mmap.c	1999/11/04 12:33:40	1.4
  +++ mmap.c	1999/11/13 00:07:16	1.5
  @@ -79,151 +79,38 @@
           return errno;
   }
   
  -ap_status_t ap_mmap_create(struct mmap_t **new, const char *fname,
  -     ap_context_t *cont)
  +ap_status_t ap_mmap_create(struct mmap_t **new, ap_file_t *file, ap_off_t offset, ap_size_t
size,
  +                ap_context_t *cont)
   {
  -    struct stat st;
  -    int fd = -1;
       void *mm;
       area_id aid = -1;
       char *areaname = "apr_mmap\0";
  -    uint32 size = 0;
  +    uint32 pages = 0;
   
  +    if (file == NULL || file->buffered || file->filedes == -1)
  +        return APR_EBADF;
       (*new) = (struct mmap_t *)ap_palloc(cont, sizeof(struct mmap_t));
       
  -    if (stat(fname, &st) == -1) { 
  -        /* we couldn't stat the file...probably doesn't exist! */
  -        return APR_ENOFILE;
  -    }
  -    if ((st.st_mode & S_IFMT) != S_IFREG) {
  -        /* oh dear, we're only doing regular files at present... */
  -        return APR_EBADF;
  -    } 
  -    size = ((st.st_size -1) / B_PAGE_SIZE) + 1;
  +    pages = ((size -1) / B_PAGE_SIZE) + 1;
   
  -    if ((fd = open(fname, O_RDONLY, 0)) == -1) {
  -        return APR_EBADF;
  -    }
  -  
  -    aid = create_area(areaname, &mm , B_ANY_ADDRESS, size * B_PAGE_SIZE, 
  +    ap_seek(file, APR_SET, &offset);
  +     
  +    aid = create_area(areaname, &mm , B_ANY_ADDRESS, pages * B_PAGE_SIZE, 
           B_FULL_LOCK, B_READ_AREA|B_WRITE_AREA);
   
  -    if (aid >= B_NO_ERROR)
  -        read(fd, mm, st.st_size);    
  -    
  -    close (fd);
       if (aid < B_NO_ERROR) {
           /* we failed to get an mmap'd file... */
           return APR_ENOMEM;
  -    }  
  -
  -    (*new)->filename = ap_pstrdup(cont, fname);
  -    (*new)->mm = mm;
  -    (*new)->sinfo = st;
  -    (*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);
  -
  -    return APR_SUCCESS;
  -}
  -
  -ap_status_t ap_mmap_open_create(struct mmap_t **new, ap_file_t *file, 
  -               ap_context_t *cont)
  -{
  -    char *mm;
  -    area_id aid = -1;
  -    char *areaname = "apr_mmap\0";
  -    uint32 size;           
  -    
  -    if (file->buffered)
  -        /* we don't yet mmap buffered files... */
  -        return APR_EBADF;
  -    if (file->filedes == -1)
  -        /* there isn't a file handle so how can we mmap?? */
  -        return APR_EBADF;
  -    (*new) = (struct mmap_t*)ap_palloc(cont, sizeof(struct mmap_t));
  -    
  -    if (!file->stated) {
  -        /* hmmmm... we need to stat the file now */
  -        struct stat st;
  -        if (stat(file->fname, &st) == -1) {
  -            /* hmm, is this fatal?? */
  -            return APR_EBADF;
  -        }
  -        file->stated = 1;
  -        file->size = st.st_size;
  -        file->atime = st.st_atime;
  -        file->mtime = st.st_mtime;
  -        file->ctime = st.st_ctime;
  -        (*new)->sinfo = st;
       }
  -    
  -    size = ((file->size -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, file->size);    
  -
  -    (*new)->filename = ap_pstrdup(cont, file->fname);
  -    (*new)->mm = mm;
  -    (*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);    
  +    if (aid >= B_NO_ERROR)
  +        read(file->filedes, mm, size);    
   
  -    (*new)->filename = ap_pstrdup(cont, file->fname);
       (*new)->mm = mm;
  -    (*new)->size = mmapsize;
  +    (*new)->size = size;
       (*new)->area = aid;
       (*new)->cntxt = cont;
  -    (*new)->statted = 0;
  -
  +               
       /* register the cleanup... */ 
       ap_register_cleanup((*new)->cntxt, (void*)(*new), mmap_cleanup,
                ap_null_cleanup);
  
  
  
  1.3       +0 -3      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- mmap_h.h	1999/11/04 12:33:40	1.2
  +++ mmap_h.h	1999/11/13 00:07:17	1.3
  @@ -64,12 +64,9 @@
   
   struct mmap_t {
       ap_context_t *cntxt;
  -    char *filename;  /* the full path to the file */
  -    struct stat sinfo;
       area_id area;
       void *mm;
       size_t size;
  -    ap_int32_t statted;
   };
   
   ap_status_t mmap_cleanup(void *);
  
  
  
  1.4       +1 -29     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- common.c	1999/11/10 15:25:04	1.3
  +++ common.c	1999/11/13 00:07:22	1.4
  @@ -87,35 +87,7 @@
   
   #if HAVE_MMAP
   
  -ap_int32_t ap_mmap_inode_compare(const void *m1, const void *m2)
  -{
  -    const ap_mmap_t *a = *(ap_mmap_t **)m1;
  -    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;
  -    }
  -    return c;
  -}
  -
  -ap_int32_t ap_mmap_filename_compare(const void *m1, const void *m2)
  -{
  -    const ap_mmap_t *a = m1;
  -    const ap_mmap_t *b = m2;
  -
  -    return strcmp(a->filename, b->filename);
  -}
  -
  -
  -
  -ap_status_t ap_mmap_offset(void **addr, ap_mmap_t *mmap, ap_size_t offset)
  +ap_status_t ap_mmap_offset(void **addr, ap_mmap_t *mmap, ap_off_t offset)
   {  
       if (offset < 0 || offset > mmap->size)
           return APR_EINVAL;
  
  
  
  1.7       +7 -90     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- mmap.c	1999/11/10 15:25:04	1.6
  +++ mmap.c	1999/11/13 00:07:23	1.7
  @@ -87,111 +87,28 @@
           return errno;
   }
   
  -ap_status_t ap_mmap_create(ap_mmap_t **new, const char * fname,
  -     ap_context_t *cont)
  +ap_status_t ap_mmap_create(ap_mmap_t **new, ap_file_t *file, ap_off_t offset, 
  +       ap_size_t size, ap_context_t *cont)
   {
  -    struct stat st;
       int fd;
       caddr_t mm;
      
  -    (*new) = (struct mmap_t *)ap_palloc(cont, sizeof(struct mmap_t));
  -    
  -    if (stat(fname, &st) == -1) {
  -        /* we couldn't stat the file...probably doesn't exist! */
  -        return APR_ENOFILE;
  -    }
  -    if ((st.st_mode & S_IFMT) != S_IFREG) {
  -        /* oh dear, we're only doing regular files at present... */
  +    if (file == NULL || file->buffered || file->filedes == -1)
           return APR_EBADF;
  -    } 
  -    if ((fd = open(fname, O_RDONLY, 0)) == -1) {
  -        return APR_EBADF;
  -    }
  -    mm = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd ,0);
  -    close (fd);
  -    if (mm == (caddr_t)-1) {
  -        /* we failed to get an mmap'd file... */
  -        return APR_ENOMEM;
  -    }
  -    (*new)->filename = ap_pstrdup(cont, fname);
  -    (*new)->mm = mm;
  -    (*new)->sinfo = st;
  -    (*new)->size = st.st_size;
  -    (*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_open_create(struct mmap_t **new, ap_file_t *file, 
  -               ap_context_t *cont)
  -{
  -    caddr_t mm;
   
  -    if (file->buffered)
  -        /* we don't yet mmap buffered files... */
  -        return APR_EBADF;
  -    if (file->filedes == -1)
  -        /* there isn't a file handle so how can we mmap?? */
  -        return APR_EBADF;
  -    (*new) = (struct mmap_t*)ap_palloc(cont, 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 */
  -        struct stat st;
  -        if (stat(file->fname, &st) == -1) {
  -            /* hmm, is this fatal?? */
  -            return APR_EBADF;
  -        }
  -        file->stated = 1;
  -        file->size = st.st_size;
  -        file->atime = st.st_atime;
  -        file->mtime = st.st_mtime;
  -        file->ctime = st.st_ctime;
  -        (*new)->sinfo = st;
  -    }
  +    ap_seek(file, APR_SET, &offset);
  +    mm = mmap(NULL, size, PROT_READ, MAP_SHARED, file->filedes ,0);
   
  -    mm = mmap(NULL, file->size, PROT_READ, MAP_SHARED, file->filedes ,0);
       if (mm == (caddr_t)-1) {
           /* we failed to get an mmap'd file... */
           return APR_ENOMEM;
       }
  -
  -    (*new)->filename = ap_pstrdup(cont, file->fname);
       (*new)->mm = mm;
  -    (*new)->size = file->size;
  +    (*new)->size = size;
       (*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_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);
  
  
  
  1.4       +0 -3      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- mmap_h.h	1999/11/10 15:25:04	1.3
  +++ mmap_h.h	1999/11/13 00:07:23	1.4
  @@ -65,11 +65,8 @@
   
   struct mmap_t {
       ap_context_t *cntxt;
  -    char *filename;  /* the full path to the file */
  -    struct stat sinfo;
       void *mm;
       size_t size;
  -    ap_int32_t statted;
   };
   
   ap_status_t mmap_cleanup(void *);
  
  
  

Mime
View raw message