diff options
author | bjh <bjh@13f79535-47bb-0310-9956-ffa450edef68> | 2000-03-16 09:48:31 +0000 |
---|---|---|
committer | bjh <bjh@13f79535-47bb-0310-9956-ffa450edef68> | 2000-03-16 09:48:31 +0000 |
commit | 5e31fce8c7e01e2bb906544df6a2d8c8d83f77a7 (patch) | |
tree | c96bb4cf9b0929029f8e5a2119bce7a32ef5fdb7 /shmem/os2 | |
parent | 4d53ff295bdca9a8df231c72a57955cbe9e6541d (diff) | |
download | libapr-5e31fce8c7e01e2bb906544df6a2d8c8d83f77a7.tar.gz |
Shared memory for OS/2
PR:
Obtained from:
Submitted by:
Reviewed by:
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@59715 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'shmem/os2')
-rw-r--r-- | shmem/os2/Makefile.in | 58 | ||||
-rw-r--r-- | shmem/os2/shmem.c | 161 |
2 files changed, 219 insertions, 0 deletions
diff --git a/shmem/os2/Makefile.in b/shmem/os2/Makefile.in new file mode 100644 index 000000000..5e25e4038 --- /dev/null +++ b/shmem/os2/Makefile.in @@ -0,0 +1,58 @@ +#CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) +#LIBS=$(EXTRA_LIBS) $(LIBS1) +#INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) +#LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) + +CC=@CC@ +RANLIB=@RANLIB@ +CFLAGS=@CFLAGS@ @OPTIM@ +LIBS=@LIBS@ +LDFLAGS=@LDFLAGS@ $(LIBS) +INCDIR=../../inc +INCDIR1=../../include +INCDIR2=../../file_io/os2 +INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I$(INCDIR2) -I. + +LIB=shmem.a + +OBJS=shmem.o + +.c.o: + $(CC) $(CFLAGS) -c $(INCLUDES) $< + +all: $(LIB) + +clean: + $(RM) -f *.o *.a *.so + +distclean: clean + -$(RM) -f Makefile + +$(OBJS): 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.tmpl. 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 | sed -e "s%\\\\\(.\)%/\\1%g" >> Makefile.new \ + && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \ + -e '1,$$s: $(INCDIR1)/: $$(INCDIR1)/:g' \ + -e '1,$$s: $(INCDIR2)/: $$(INCDIR2)/:g' \ + -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \ + > Makefile.in \ + && rm Makefile.new + +# DO NOT REMOVE +shmem.o: shmem.c $(INCDIR1)/apr_general.h $(INCDIR1)/apr.h \ + $(INCDIR1)/apr_errno.h $(INCDIR1)/apr_shmem.h \ + $(INCDIR1)/apr_lib.h $(INCDIR1)/apr_file_io.h \ + $(INCDIR1)/apr_time.h $(INCDIR1)/apr_thread_proc.h diff --git a/shmem/os2/shmem.c b/shmem/os2/shmem.c new file mode 100644 index 000000000..7f33fb016 --- /dev/null +++ b/shmem/os2/shmem.c @@ -0,0 +1,161 @@ +/* ==================================================================== + * 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/>. + * + */ + +#include "apr_general.h" +#include "apr_shmem.h" +#include "apr_errno.h" +#include "apr_lib.h" +#include <umalloc.h> +#include <stdlib.h> +#define INCL_DOS +#include <os2.h> + +int os2errno( unsigned long oserror ); + +struct shmem_t { + void *memblock; + Heap_t heap; +}; + + + +ap_status_t ap_shm_init(struct shmem_t **m, ap_size_t reqsize, const char *file, ap_context_t *cont) +{ + int rc; + struct shmem_t *newm = (struct shmem_t *)ap_palloc(cont, sizeof(struct shmem_t)); + char *name = NULL; + + if (file) + name = ap_pstrcat(cont, "\\SHAREMEM\\", file, NULL); + + rc = DosAllocSharedMem(&(newm->memblock), name, reqsize, PAG_COMMIT|OBJ_GETTABLE|PAG_READ|PAG_WRITE); + + if (rc) + return os2errno(rc); + + newm->heap = _ucreate(newm->memblock, reqsize, !_BLOCK_CLEAN, _HEAP_REGULAR|_HEAP_SHARED, NULL, NULL); + _uopen(newm->heap); + *m = newm; + return APR_SUCCESS; +} + + + +ap_status_t ap_shm_destroy(struct shmem_t *m) +{ + _uclose(m->heap); + _udestroy(m->heap, _FORCE); + DosFreeMem(m->memblock); + return APR_SUCCESS; +} + + + +void *ap_shm_malloc(struct shmem_t *m, ap_size_t reqsize) +{ + return _umalloc(m->heap, reqsize); +} + + + +void *ap_shm_calloc(struct shmem_t *m, ap_size_t size) +{ + return _ucalloc(m->heap, size, 1); +} + + + +ap_status_t ap_shm_free(struct shmem_t *m, void *entity) +{ + free(entity); + return APR_SUCCESS; +} + + + +ap_status_t ap_get_shm_name(ap_shmem_t *c, ap_shm_name_t **name) +{ + return APR_ANONYMOUS; +} + + + +ap_status_t ap_set_shm_name(ap_shmem_t *c, ap_shm_name_t *name) +{ + return APR_ANONYMOUS; +} + + + +ap_status_t ap_open_shmem(struct shmem_t *m) +{ + int rc; + + rc = DosGetSharedMem(m->memblock, PAG_READ|PAG_WRITE); + + if (rc) + return os2errno(rc); + + _uopen(m->heap); + return APR_SUCCESS; +} + + + +ap_status_t ap_shm_avail(struct shmem_t *c, ap_size_t *size) +{ + + return APR_ENOTIMPL; +} |