apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: apr/shmem/os2 Makefile.in shm.c
Date Thu, 10 Jan 2002 02:09:20 GMT
bjh         02/01/09 18:09:20

  Modified:    shmem/os2 Makefile.in shm.c
  Log:
  OS/2: Pound the new shm code into some kind of working order.
  
  Revision  Changes    Path
  1.8       +1 -1      apr/shmem/os2/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/shmem/os2/Makefile.in,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Makefile.in	9 Jan 2001 11:06:14 -0000	1.7
  +++ Makefile.in	10 Jan 2002 02:09:20 -0000	1.8
  @@ -1,5 +1,5 @@
   
  -TARGETS = shmem.lo
  +TARGETS = shm.lo
   
   # bring in rules.mk for standard functionality
   @INCLUDE_RULES@
  
  
  
  1.2       +48 -24    apr/shmem/os2/shm.c
  
  Index: shm.c
  ===================================================================
  RCS file: /home/cvs/apr/shmem/os2/shm.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- shm.c	10 Jan 2002 00:20:06 -0000	1.1
  +++ shm.c	10 Jan 2002 02:09:20 -0000	1.2
  @@ -53,69 +53,93 @@
    */
   
   #include "apr_general.h"
  -#include "apr_shmem.h"
  +#include "apr_shm.h"
   #include "apr_errno.h"
   #include "apr_lib.h"
   #include "apr_strings.h"
  -#include <umalloc.h>
  -#include <stdlib.h>
   
  -struct apr_shmem_t {
  +struct apr_shm_t {
  +    apr_pool_t *pool;
       void *memblock;
  -    Heap_t heap;
   };
   
  -APR_DECLARE(apr_status_t) apr_shm_init(apr_shmem_t **m, apr_size_t reqsize, const char
*filename, apr_pool_t *cont)
  +APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
  +                                         apr_size_t reqsize,
  +                                         const char *filename,
  +                                         apr_pool_t *pool)
   {
       int rc;
  -    apr_shmem_t *newm = (apr_shmem_t *)apr_palloc(cont, sizeof(apr_shmem_t));
  +    apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t));
       char *name = NULL;
       ULONG flags = PAG_COMMIT|PAG_READ|PAG_WRITE;
   
  -    if (file)
  -        name = apr_pstrcat(cont, "\\SHAREMEM\\", file, NULL);
  +    newm->pool = pool;
   
  -    if (name == NULL)
  +    if (filename) {
  +        name = apr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL);
  +    }
  +
  +    if (name == NULL) {
           flags |= OBJ_GETTABLE;
  +    }
   
  -    reqsize += 1024; /* Allow some overhead for heap structures */
       rc = DosAllocSharedMem(&(newm->memblock), name, reqsize, flags);
   
  -    if (rc)
  +    if (rc) {
           return APR_OS2_STATUS(rc);
  +    }
   
  -    newm->heap = _ucreate(newm->memblock, reqsize, !_BLOCK_CLEAN, _HEAP_REGULAR|_HEAP_SHARED,
NULL, NULL);
  -    _uopen(newm->heap);
       *m = newm;
       return APR_SUCCESS;
   }
   
  -APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shmem_t *m)
  +APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m)
   {
  -    _uclose(m->heap);
  -    _udestroy(m->heap, _FORCE);
       DosFreeMem(m->memblock);
       return APR_SUCCESS;
   }
   
  -APR_DECLARE(apr_status_t) apr_shm_attach(apr_shmem_t **m,
  +APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
                                            const char *filename,
                                            apr_pool_t *pool)
   {
  -    return APR_ENOTIMPL;
  +    int rc;
  +    apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t));
  +    char *name = NULL;
  +    ULONG flags = PAG_COMMIT|PAG_READ|PAG_WRITE;
  +
  +    newm->pool = pool;
  +    name = apr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL);
  +
  +    rc = DosGetNamedSharedMem(&(newm->memblock), name, flags);
  +
  +    if (rc) {
  +        return APR_FROM_OS_ERROR(rc);
  +    }
  +
  +    *m = newm;
  +    return APR_SUCCESS;
   }
   
  -APR_DECLARE(apr_status_t) apr_shm_detach(apr_shmem_t *m)
  +APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m)
   {
  -    return APR_ENOTIMPL;
  +    int rc = 0;
  +
  +    if (m->memblock) {
  +        rc = DosFreeMem(m->memblock);
  +    }
  +
  +    return APR_FROM_OS_ERROR(rc);
   }
   
   APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m)
   {
  -    return APR_ENOTIMPL;
  +    return m->memblock;
   }
   
   APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m)
   {
  -    return APR_ENOTIMPL;
  -
  +    ULONG flags, size = 0x1000000;
  +    DosQueryMem(m->memblock, &size, &flags);
  +    return size;
  +}
  
  
  

Mime
View raw message