diff options
author | rbb <rbb@13f79535-47bb-0310-9956-ffa450edef68> | 2000-05-16 17:12:45 +0000 |
---|---|---|
committer | rbb <rbb@13f79535-47bb-0310-9956-ffa450edef68> | 2000-05-16 17:12:45 +0000 |
commit | 5da35d9a90f3352feb5432a1e2dcaf82029215da (patch) | |
tree | 0b096261d66bfa750f398272121db273f70090ba /mmap | |
parent | 5bf71bc0c78d961124ca9aa621991e0630407074 (diff) | |
download | libapr-5da35d9a90f3352feb5432a1e2dcaf82029215da.tar.gz |
Update the unix code to support BeOS. Remove the now un-necessary BeOS
directory.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@60046 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'mmap')
-rw-r--r-- | mmap/beos/Makefile.in | 63 | ||||
-rw-r--r-- | mmap/beos/mmap.c | 122 | ||||
-rw-r--r-- | mmap/beos/mmap_common.c | 2 | ||||
-rw-r--r-- | mmap/beos/mmap_h.h | 79 | ||||
-rw-r--r-- | mmap/unix/common.c | 4 | ||||
-rw-r--r-- | mmap/unix/mmap.c | 45 | ||||
-rw-r--r-- | mmap/unix/mmap_h.h | 7 |
7 files changed, 39 insertions, 283 deletions
diff --git a/mmap/beos/Makefile.in b/mmap/beos/Makefile.in deleted file mode 100644 index 4216af163..000000000 --- a/mmap/beos/Makefile.in +++ /dev/null @@ -1,63 +0,0 @@ -#CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) -#LIBS=$(EXTRA_LIBS) $(LIBS1) -#INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) -#LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) - -RM=@RM@ -CC=@CC@ -RANLIB=@RANLIB@ -CFLAGS=@CFLAGS@ @OPTIM@ -LIBS=@LIBS@ -LDFLAGS=@LDFLAGS@ $(LIBS) -INCDIR=../../include -I../../file_io/unix -INCLUDES=-I$(INCDIR) -I. - -LIB=libmmap.a - -OBJS=mmap.o mmap_common.o - -.c.o: - $(CC) $(CFLAGS) -c $(INCLUDES) $< - -all: $(LIB) - -clean: - $(RM) -f *.o *.a *.so - -distclean: clean - -$(RM) -f Makefile - - -$(LIB): $(OBJS) - $(RM) -f $@ - $(AR) cr $@ $(OBJS) - $(RANLIB) $@ - -# -# We really don't expect end users to use this rule. It works only with -# gcc, and rebuilds Makefile.in. You have to re-run configure after -# using it. -# -depend: - cp Makefile.in Makefile.in.bak \ - && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.in > Makefile.new \ - && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \ - && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \ - -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \ - > Makefile.in \ - && rm Makefile.new - -# DO NOT REMOVE -mmap.o: mmap.c mmap_h.h ../../include/apr_general.h \ - ../../include/apr.h ../../include/apr_errno.h \ - ../../include/apr_mmap.h ../../include/apr_network_io.h \ - ../../include/apr_file_io.h ../../include/apr_portable.h \ - ../../include/apr_thread_proc.h ../../include/apr_lock.h \ - ../../include/apr_time.h ../../include/apr_lib.h \ - ../../file_io/unix/fileio.h ../../include/apr_private.h -mmap_common.o: mmap_common.c ../unix/common.c ../unix/../beos/mmap_h.h \ - ../../include/apr_general.h ../../include/apr.h \ - ../../include/apr_errno.h ../../include/apr_mmap.h \ - ../../include/apr_network_io.h ../../include/apr_file_io.h \ - ../../include/apr_portable.h ../../include/apr_thread_proc.h \ - ../../include/apr_lock.h ../../include/apr_time.h diff --git a/mmap/beos/mmap.c b/mmap/beos/mmap.c deleted file mode 100644 index f7d97c457..000000000 --- a/mmap/beos/mmap.c +++ /dev/null @@ -1,122 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. 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. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" 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 name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``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 SOFTWARE FOUNDATION 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 Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "mmap_h.h" - -static ap_status_t mmap_cleanup(void *themmap) -{ - ap_mmap_t *mm = themmap; - int rv; - rv = delete_area(mm->area); - - if (rv == 0) { - mm->mm = 0; - mm->area = -1; - return APR_SUCCESS; - } - else - return errno; -} - -ap_status_t ap_mmap_create(ap_mmap_t **new, ap_file_t *file, ap_off_t offset, ap_size_t size, - ap_pool_t *cont) -{ - void *mm; - area_id aid = -1; - char *areaname = "apr_mmap\0"; - uint32 pages = 0; - - if (file == NULL || file->buffered || file->filedes == -1) - return APR_EBADF; - (*new) = (ap_mmap_t *)ap_palloc(cont, sizeof(ap_mmap_t)); - - pages = ((size -1) / B_PAGE_SIZE) + 1; - - 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) { - /* we failed to get an mmap'd file... */ - return APR_ENOMEM; - } - - if (aid >= B_NO_ERROR) - read(file->filedes, mm, size); - - (*new)->mm = mm; - (*new)->size = size; - (*new)->area = aid; - (*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(ap_mmap_t *mmap) -{ - ap_status_t rv; - if (mmap->area == -1) - return APR_ENOENT; - - if ((rv = mmap_cleanup(mmap)) == APR_SUCCESS) { - ap_kill_cleanup(mmap->cntxt, mmap, mmap_cleanup); - return APR_SUCCESS; - } - return rv; -} diff --git a/mmap/beos/mmap_common.c b/mmap/beos/mmap_common.c deleted file mode 100644 index 7742d0f9a..000000000 --- a/mmap/beos/mmap_common.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../unix/common.c" - diff --git a/mmap/beos/mmap_h.h b/mmap/beos/mmap_h.h deleted file mode 100644 index 898953771..000000000 --- a/mmap/beos/mmap_h.h +++ /dev/null @@ -1,79 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. 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. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" 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 name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``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 SOFTWARE FOUNDATION 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 Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#ifndef MMAP_H_H -#define MMAP_H_H - -#include "apr_general.h" -#include "apr_mmap.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_portable.h" -#include "apr_lib.h" -#include "fileio.h" -#include <sys/stat.h> -#include <kernel/OS.h> -#include <errno.h> -#include <string.h> -#include <stdio.h> - -struct ap_mmap_t { - ap_pool_t *cntxt; - area_id area; - void *mm; - size_t size; -}; - -#endif /* ! FILE_IO_H */ - diff --git a/mmap/unix/common.c b/mmap/unix/common.c index 34eb8fe92..d2fc6cc01 100644 --- a/mmap/unix/common.c +++ b/mmap/unix/common.c @@ -61,11 +61,7 @@ * */ -#ifdef BEOS -#include "../beos/mmap_h.h" -#else #include "mmap_h.h" -#endif #if HAVE_MMAP diff --git a/mmap/unix/mmap.c b/mmap/unix/mmap.c index aec212265..cd6075017 100644 --- a/mmap/unix/mmap.c +++ b/mmap/unix/mmap.c @@ -52,12 +52,7 @@ * <http://www.apache.org/>. */ -#ifdef BEOS -#include "../beos/mmap_h.h" -#else #include "mmap_h.h" -#endif - #include "apr_portable.h" #if HAVE_MMAP @@ -66,33 +61,65 @@ static ap_status_t mmap_cleanup(void *themmap) { ap_mmap_t *mm = themmap; int rv; +#ifdef BEOS + rv = delete_area(mm->area); + + if (rv == 0) { + mm->mm = (caddr_t)-1; + return APR_SUCCESS; + } +#else rv = munmap(mm->mm, mm->size); if (rv == 0) { mm->mm = (caddr_t)-1; return APR_SUCCESS; } - else - return errno; +#endif + return errno; } ap_status_t ap_mmap_create(ap_mmap_t **new, ap_file_t *file, ap_off_t offset, ap_size_t size, ap_pool_t *cont) { +#ifdef BEOS + void *mm; + area_id aid = -1; + char *areaname = "apr_mmap\0"; + uint32 pages = 0; +#else caddr_t mm; +#endif - if (file == NULL || file->filedes == -1) + if (file == NULL || file->filedes == -1 || file->buffered) return APR_EBADF; - (*new) = (ap_mmap_t *)ap_pcalloc(cont, sizeof(ap_mmap_t)); ap_seek(file, APR_SET, &offset); +#ifdef BEOS + pages = ((size -1) / B_PAGE_SIZE) + 1; + + 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) { + /* we failed to get an mmap'd file... */ + return APR_ENOMEM; + } + + if (aid >= B_NO_ERROR) + read(file->filedes, mm, size); + (*new)->area = aid; +#else + mm = mmap(NULL, size, PROT_READ, MAP_SHARED, file->filedes ,0); if (mm == (caddr_t)-1) { /* we failed to get an mmap'd file... */ return APR_ENOMEM; } +#endif + (*new)->mm = mm; (*new)->size = size; (*new)->cntxt = cont; diff --git a/mmap/unix/mmap_h.h b/mmap/unix/mmap_h.h index fbb42b63d..c698528b2 100644 --- a/mmap/unix/mmap_h.h +++ b/mmap/unix/mmap_h.h @@ -60,11 +60,7 @@ #include "apr_mmap.h" #include "apr_errno.h" #include "fileio.h" -#ifdef BEOS -#include "../beos/mmap_h.h" -#else #include "mmap_h.h" -#endif /* System headers required for the mmap library */ #ifdef BEOS @@ -86,6 +82,9 @@ struct ap_mmap_t { ap_pool_t *cntxt; +#ifdef BEOS + area_id; +#endif void *mm; size_t size; }; |