diff options
author | dreid <dreid@13f79535-47bb-0310-9956-ffa450edef68> | 1999-11-03 12:30:59 +0000 |
---|---|---|
committer | dreid <dreid@13f79535-47bb-0310-9956-ffa450edef68> | 1999-11-03 12:30:59 +0000 |
commit | c2703b94e14b46d63e53ce2f883a603ab74406ed (patch) | |
tree | 553c7f5ee1e87ea98ac43039e10d4168af6090b7 /mmap | |
parent | c79e7284eca9aecb1fc6abe18449dcd940544028 (diff) | |
download | libapr-c2703b94e14b46d63e53ce2f883a603ab74406ed.tar.gz |
Add more functions to the APR mmap.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@59443 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'mmap')
-rw-r--r-- | mmap/beos/Makefile.in | 17 | ||||
-rw-r--r-- | mmap/beos/common.c | 3 | ||||
-rw-r--r-- | mmap/beos/mmap.c | 8 | ||||
-rw-r--r-- | mmap/unix/Makefile.in | 2 | ||||
-rw-r--r-- | mmap/unix/common.c | 118 | ||||
-rw-r--r-- | mmap/unix/mmap.c | 2 |
6 files changed, 143 insertions, 7 deletions
diff --git a/mmap/beos/Makefile.in b/mmap/beos/Makefile.in index a5f135fe4..b66162601 100644 --- a/mmap/beos/Makefile.in +++ b/mmap/beos/Makefile.in @@ -15,7 +15,7 @@ INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I. LIB=libmmap.a -OBJS=mmap.o +OBJS=mmap.o common.o .c.o: $(CC) $(CFLAGS) -c $(INCLUDES) $< @@ -50,3 +50,18 @@ depend: && rm Makefile.new # DO NOT REMOVE +common.o: common.c ../unix/common.c ../unix/../beos/mmap_h.h \ + ../../include/apr_general.h ../../include/apr_config.h \ + ../../include/apr_errno.h ../../include/apr_mmap.h \ + ../../include/apr_network_io.h ../../include/apr_portable.h \ + ../../include/apr_thread_proc.h ../../include/apr_file_io.h \ + ../../include/apr_win.h ../../include/apr_lock.h \ + ../../include/apr_time.h ../../file_io/unix/fileio.h \ + ../../include/apr_lib.h +mmap.o: mmap.c mmap_h.h ../../include/apr_general.h \ + ../../include/apr_config.h ../../include/apr_errno.h \ + ../../include/apr_mmap.h ../../include/apr_network_io.h \ + ../../include/apr_portable.h ../../include/apr_thread_proc.h \ + ../../include/apr_file_io.h ../../include/apr_win.h \ + ../../include/apr_lock.h ../../include/apr_time.h \ + ../../include/apr_lib.h ../../file_io/unix/fileio.h diff --git a/mmap/beos/common.c b/mmap/beos/common.c new file mode 100644 index 000000000..02ef458c8 --- /dev/null +++ b/mmap/beos/common.c @@ -0,0 +1,3 @@ +#include "../unix/common.c" + + diff --git a/mmap/beos/mmap.c b/mmap/beos/mmap.c index 536679149..6ffa2c732 100644 --- a/mmap/beos/mmap.c +++ b/mmap/beos/mmap.c @@ -134,7 +134,7 @@ ap_status_t ap_mmap_create(struct mmap_t **new, const char *fname, ap_status_t ap_mmap_open_create(struct mmap_t **new, ap_file_t *file, ap_context_t *cont) { - void *mm; + char *mm; area_id aid = -1; char *areaname = "apr_mmap\0"; uint32 size; @@ -164,8 +164,8 @@ ap_status_t ap_mmap_open_create(struct mmap_t **new, ap_file_t *file, size = ((file->size -1) / B_PAGE_SIZE) + 1; - aid = create_area(areaname, &mm, B_ANY_ADDRESS, size * B_PAGE_SIZE, - B_LAZY_LOCK, B_READ_AREA|B_WRITE_AREA); + 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) { @@ -180,7 +180,7 @@ ap_status_t ap_mmap_open_create(struct mmap_t **new, ap_file_t *file, (*new)->size = file->size; (*new)->area = aid; (*new)->cntxt = cont; - + /* register the cleanup... */ ap_register_cleanup((*new)->cntxt, (void*)(*new), mmap_cleanup, ap_null_cleanup); diff --git a/mmap/unix/Makefile.in b/mmap/unix/Makefile.in index f8551b27c..480fde363 100644 --- a/mmap/unix/Makefile.in +++ b/mmap/unix/Makefile.in @@ -15,7 +15,7 @@ INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I. LIB=libmmap.a -OBJS=mmap.o +OBJS=mmap.o common.o .c.o: $(CC) $(CFLAGS) -c $(INCLUDES) $< diff --git a/mmap/unix/common.c b/mmap/unix/common.c new file mode 100644 index 000000000..7e59fcf37 --- /dev/null +++ b/mmap/unix/common.c @@ -0,0 +1,118 @@ +/* ==================================================================== + * Copyright (c) 1999 The Apache Group. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the Apache Group + * for use in the Apache HTTP server project (http://www.apache.org/)." + * + * 4. The names "Apache Server" and "Apache Group" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the Apache Group + * for use in the Apache HTTP server project (http://www.apache.org/)." + * + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Group. + * For more information on the Apache Group and the Apache HTTP server + * project, please see <http://www.apache.org/>. + * + */ + +/* common .c + * This file has any function that is truly common and platform + * neutral. Or at least that's the theory. + * + * The header files are a problem so there are a few #ifdef's to take + * care of those. + * + */ + +#if HAVE_MMAP + +#ifdef BEOS +#include "../beos/mmap_h.h" +#include <kernel/OS.h> +#else +#include "mmap_h.h" +#include <sys/mman.h> +#endif + +#include "fileio.h" +#include "apr_mmap.h" +#include "apr_general.h" +#include "apr_portable.h" +#include "apr_lib.h" +#include <errno.h> +#include <string.h> +#include <stdio.h> + + +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; + + 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) +{ + if (offset < 0 || offset > mmap->size) + return APR_EINVAL; + + (*addr) = mmap->mm + offset; + fprintf(stderr,"ap_mmap_offset (%p, %d) ==> %p\n",mmap->mm, offset, (*addr)); + return APR_SUCCESS; +} + +#endif diff --git a/mmap/unix/mmap.c b/mmap/unix/mmap.c index 47bdc7f81..6d1afcbc6 100644 --- a/mmap/unix/mmap.c +++ b/mmap/unix/mmap.c @@ -111,7 +111,7 @@ ap_status_t ap_mmap_create(ap_mmap_t **new, const char * fname, (*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); |