1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. 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.
22 * @brief APR Shared Memory Routines
26 #include "apr_pools.h"
27 #include "apr_errno.h"
31 #endif /* __cplusplus */
34 * @defgroup apr_shm Shared Memory Routines
40 * Private, platform-specific data struture representing a shared memory
43 typedef struct apr_shm_t apr_shm_t
;
46 * Create and make accessable a shared memory segment.
47 * @param m The shared memory structure to create.
48 * @param reqsize The desired size of the segment.
49 * @param filename The file to use for shared memory on platforms that
51 * @param pool the pool from which to allocate the shared memory
53 * @remark A note about Anonymous vs. Named shared memory segments:
54 * Not all plaforms support anonymous shared memory segments, but in
55 * some cases it is prefered over other types of shared memory
56 * implementations. Passing a NULL 'file' parameter to this function
57 * will cause the subsystem to use anonymous shared memory segments.
58 * If such a system is not available, APR_ENOTIMPL is returned.
59 * @remark A note about allocation sizes:
60 * On some platforms it is necessary to store some metainformation
61 * about the segment within the actual segment. In order to supply
62 * the caller with the requested size it may be necessary for the
63 * implementation to request a slightly greater segment length
64 * from the subsystem. In all cases, the apr_shm_baseaddr_get()
65 * function will return the first usable byte of memory.
68 APR_DECLARE(apr_status_t
) apr_shm_create(apr_shm_t
**m
,
74 * Destroy a shared memory segment and associated memory.
75 * @param m The shared memory segment structure to destroy.
77 APR_DECLARE(apr_status_t
) apr_shm_destroy(apr_shm_t
*m
);
80 * Attach to a shared memory segment that was created
82 * @param m The shared memory structure to create.
83 * @param filename The file used to create the original segment.
84 * (This MUST match the original filename.)
85 * @param pool the pool from which to allocate the shared memory
86 * structure for this process.
88 APR_DECLARE(apr_status_t
) apr_shm_attach(apr_shm_t
**m
,
93 * Detach from a shared memory segment without destroying it.
94 * @param m The shared memory structure representing the segment
97 APR_DECLARE(apr_status_t
) apr_shm_detach(apr_shm_t
*m
);
100 * Retrieve the base address of the shared memory segment.
101 * NOTE: This address is only usable within the callers address
102 * space, since this API does not guarantee that other attaching
103 * processes will maintain the same address mapping.
104 * @param m The shared memory segment from which to retrieve
107 APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t
*m
);
110 * Retrieve the length of a shared memory segment in bytes.
111 * @param m The shared memory segment from which to retrieve
112 * the segment length.
114 APR_DECLARE(apr_size_t
) apr_shm_size_get(const apr_shm_t
*m
);
117 * Get the pool used by this shared memory segment.
119 APR_POOL_DECLARE_ACCESSOR(shm
);
127 #endif /* APR_SHM_T */