1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
#include "apr_general.h"
19
#include "apr_errno.h"
21
#include "apr_strings.h"
22
#include "apr_portable.h"
29
APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
35
apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t));
37
ULONG flags = PAG_COMMIT|PAG_READ|PAG_WRITE;
42
name = apr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL);
46
flags |= OBJ_GETTABLE;
49
rc = DosAllocSharedMem(&(newm->memblock), name, reqsize, flags);
52
return APR_OS2_STATUS(rc);
59
APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m)
61
DosFreeMem(m->memblock);
65
APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename,
71
APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
76
apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t));
78
ULONG flags = PAG_READ|PAG_WRITE;
81
name = apr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL);
83
rc = DosGetNamedSharedMem(&(newm->memblock), name, flags);
86
return APR_FROM_OS_ERROR(rc);
93
APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m)
98
rc = DosFreeMem(m->memblock);
101
return APR_FROM_OS_ERROR(rc);
104
APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m)
109
APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m)
111
ULONG flags, size = 0x1000000;
112
DosQueryMem(m->memblock, &size, &flags);
116
APR_POOL_IMPLEMENT_ACCESSOR(shm)
118
APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm,
121
*osshm = shm->memblock;
125
APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m,
130
apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t));
131
ULONG flags = PAG_COMMIT|PAG_READ|PAG_WRITE;
135
rc = DosGetSharedMem(&(newm->memblock), flags);
138
return APR_FROM_OS_ERROR(rc);