| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Licensed to the Apache Software Foundation (ASF) under one or more | |
| 3 * contributor license agreements. See the NOTICE file distributed with | |
| 4 * this work for additional information regarding copyright ownership. | |
| 5 * The ASF licenses this file to You under the Apache License, Version 2.0 | |
| 6 * (the "License"); you may not use this file except in compliance with | |
| 7 * the License. You may obtain a copy of the License at | |
| 8 * | |
| 9 * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 * | |
| 11 * Unless required by applicable law or agreed to in writing, software | |
| 12 * distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 * See the License for the specific language governing permissions and | |
| 15 * limitations under the License. | |
| 16 */ | |
| 17 | |
| 18 package org.apache.tomcat.jni; | |
| 19 | |
| 20 import java.nio.ByteBuffer; | |
| 21 | |
| 22 /** Shm | |
| 23 * | |
| 24 * @author Mladen Turk | |
| 25 */ | |
| 26 public class Shm { | |
| 27 | |
| 28 /** | |
| 29 * Create and make accessible a shared memory segment. | |
| 30 * <br> | |
| 31 * A note about Anonymous vs. Named shared memory segments:<br> | |
| 32 * Not all platforms support anonymous shared memory segments, but i
n | |
| 33 * some cases it is preferred over other types of shared memory | |
| 34 * implementations. Passing a NULL 'file' parameter to this function | |
| 35 * will cause the subsystem to use anonymous shared memory segments. | |
| 36 * If such a system is not available, APR_ENOTIMPL is returned. | |
| 37 * <br> | |
| 38 * A note about allocation sizes:<br> | |
| 39 * On some platforms it is necessary to store some metainformation | |
| 40 * about the segment within the actual segment. In order to supply | |
| 41 * the caller with the requested size it may be necessary for the | |
| 42 * implementation to request a slightly greater segment length | |
| 43 * from the subsystem. In all cases, the apr_shm_baseaddr_get() | |
| 44 * function will return the first usable byte of memory. | |
| 45 * @param reqsize The desired size of the segment. | |
| 46 * @param filename The file to use for shared memory on platforms that | |
| 47 * require it. | |
| 48 * @param pool the pool from which to allocate the shared memory | |
| 49 * structure. | |
| 50 * @return The created shared memory structure. | |
| 51 * | |
| 52 */ | |
| 53 public static native long create(long reqsize, String filename, long pool) | |
| 54 throws Error; | |
| 55 | |
| 56 /** | |
| 57 * Remove shared memory segment associated with a filename. | |
| 58 * <br> | |
| 59 * This function is only supported on platforms which support | |
| 60 * name-based shared memory segments, and will return APR_ENOTIMPL on | |
| 61 * platforms without such support. | |
| 62 * @param filename The filename associated with shared-memory segment which | |
| 63 * needs to be removed | |
| 64 * @param pool The pool used for file operations | |
| 65 */ | |
| 66 public static native int remove(String filename, long pool); | |
| 67 | |
| 68 /** | |
| 69 * Destroy a shared memory segment and associated memory. | |
| 70 * @param m The shared memory segment structure to destroy. | |
| 71 */ | |
| 72 public static native int destroy(long m); | |
| 73 | |
| 74 /** | |
| 75 * Attach to a shared memory segment that was created | |
| 76 * by another process. | |
| 77 * @param filename The file used to create the original segment. | |
| 78 * (This MUST match the original filename.) | |
| 79 * @param pool the pool from which to allocate the shared memory | |
| 80 * structure for this process. | |
| 81 * @return The created shared memory structure. | |
| 82 */ | |
| 83 public static native long attach(String filename, long pool) | |
| 84 throws Error; | |
| 85 | |
| 86 /** | |
| 87 * Detach from a shared memory segment without destroying it. | |
| 88 * @param m The shared memory structure representing the segment | |
| 89 * to detach from. | |
| 90 */ | |
| 91 public static native int detach(long m); | |
| 92 | |
| 93 /** | |
| 94 * Retrieve the base address of the shared memory segment. | |
| 95 * NOTE: This address is only usable within the callers address | |
| 96 * space, since this API does not guarantee that other attaching | |
| 97 * processes will maintain the same address mapping. | |
| 98 * @param m The shared memory segment from which to retrieve | |
| 99 * the base address. | |
| 100 * @return address, aligned by APR_ALIGN_DEFAULT. | |
| 101 */ | |
| 102 public static native long baseaddr(long m); | |
| 103 | |
| 104 /** | |
| 105 * Retrieve the length of a shared memory segment in bytes. | |
| 106 * @param m The shared memory segment from which to retrieve | |
| 107 * the segment length. | |
| 108 */ | |
| 109 public static native long size(long m); | |
| 110 | |
| 111 /** | |
| 112 * Retrieve new ByteBuffer base address of the shared memory segment. | |
| 113 * NOTE: This address is only usable within the callers address | |
| 114 * space, since this API does not guarantee that other attaching | |
| 115 * processes will maintain the same address mapping. | |
| 116 * @param m The shared memory segment from which to retrieve | |
| 117 * the base address. | |
| 118 * @return address, aligned by APR_ALIGN_DEFAULT. | |
| 119 */ | |
| 120 public static native ByteBuffer buffer(long m); | |
| 121 | |
| 122 } | |
| OLD | NEW |