| John Reck | 9f5599b | 2017-08-07 11:18:40 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright (C) 2017 The Android Open Source Project | 
 | 3 |  * | 
 | 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 | 
 | 7 |  * | 
 | 8 |  *      http://www.apache.org/licenses/LICENSE-2.0 | 
 | 9 |  * | 
 | 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. | 
 | 15 |  */ | 
 | 16 |  | 
 | 17 | /** | 
 | 18 |  * @addtogroup Memory | 
 | 19 |  * @{ | 
 | 20 |  */ | 
 | 21 |  | 
 | 22 | /** | 
 | 23 |  * @file sharedmem_jni.h | 
| Elliott Hughes | 0c75712 | 2018-07-31 12:10:19 -0700 | [diff] [blame] | 24 |  * @brief Shared memory buffers that can be shared across process. | 
| John Reck | 9f5599b | 2017-08-07 11:18:40 -0700 | [diff] [blame] | 25 |  */ | 
 | 26 |  | 
 | 27 | #ifndef ANDROID_SHARED_MEMORY_JNI_H | 
 | 28 | #define ANDROID_SHARED_MEMORY_JNI_H | 
 | 29 |  | 
 | 30 | #include <jni.h> | 
 | 31 | #include <android/sharedmem.h> | 
 | 32 | #include <stddef.h> | 
| Ryan Prichard | 0277d0a | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 33 | #include <sys/cdefs.h> | 
| John Reck | 9f5599b | 2017-08-07 11:18:40 -0700 | [diff] [blame] | 34 |  | 
 | 35 | /****************************************************************** | 
 | 36 |  * | 
 | 37 |  * IMPORTANT NOTICE: | 
 | 38 |  * | 
 | 39 |  *   This file is part of Android's set of stable system headers | 
 | 40 |  *   exposed by the Android NDK (Native Development Kit). | 
 | 41 |  * | 
 | 42 |  *   Third-party source AND binary code relies on the definitions | 
 | 43 |  *   here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. | 
 | 44 |  * | 
 | 45 |  *   - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) | 
 | 46 |  *   - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS | 
 | 47 |  *   - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY | 
 | 48 |  *   - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES | 
 | 49 |  */ | 
 | 50 |  | 
| John Reck | 9f5599b | 2017-08-07 11:18:40 -0700 | [diff] [blame] | 51 | #ifdef __cplusplus | 
 | 52 | extern "C" { | 
 | 53 | #endif | 
 | 54 |  | 
| Ryan Prichard | 0277d0a | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 55 | #if __ANDROID_API__ >= 27 | 
 | 56 |  | 
| John Reck | 9f5599b | 2017-08-07 11:18:40 -0700 | [diff] [blame] | 57 | /** | 
 | 58 |  * Returns a dup'd FD from the given Java android.os.SharedMemory object. The returned file | 
 | 59 |  * descriptor has all the same properties & capabilities as the FD returned from | 
 | 60 |  * ASharedMemory_create(), however the protection flags will be the same as those of the | 
 | 61 |  * android.os.SharedMemory object. | 
 | 62 |  * | 
 | 63 |  * Use close() to release the shared memory region. | 
 | 64 |  * | 
| Elliott Hughes | 0c75712 | 2018-07-31 12:10:19 -0700 | [diff] [blame] | 65 |  * Available since API level 27. | 
 | 66 |  * | 
| John Reck | 9f5599b | 2017-08-07 11:18:40 -0700 | [diff] [blame] | 67 |  * \param env The JNIEnv* pointer | 
 | 68 |  * \param sharedMemory The Java android.os.SharedMemory object | 
 | 69 |  * \return file descriptor that denotes the shared memory; -1 if the shared memory object is | 
| John Reck | 4c05583 | 2017-08-18 09:44:38 -0700 | [diff] [blame] | 70 |  *      already closed, if the JNIEnv or jobject is NULL, or if there are too many open file | 
 | 71 |  *      descriptors (errno=EMFILE) | 
| John Reck | 9f5599b | 2017-08-07 11:18:40 -0700 | [diff] [blame] | 72 |  */ | 
| Elliott Hughes | c2fcafc | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 73 | int ASharedMemory_dupFromJava(JNIEnv* env, jobject sharedMemory) __INTRODUCED_IN(27); | 
| John Reck | 9f5599b | 2017-08-07 11:18:40 -0700 | [diff] [blame] | 74 |  | 
| Ryan Prichard | 0277d0a | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 75 | #endif // __ANDROID_API__ >= 27 | 
 | 76 |  | 
| John Reck | 9f5599b | 2017-08-07 11:18:40 -0700 | [diff] [blame] | 77 | #ifdef __cplusplus | 
 | 78 | }; | 
 | 79 | #endif | 
 | 80 |  | 
 | 81 | #endif // ANDROID_SHARED_MEMORY_JNI_H | 
 | 82 |  | 
 | 83 | /** @} */ |