xref: /aosp_15_r20/external/libchrome/third_party/ashmem/ashmem.h (revision 635a864187cb8b6c713ff48b7e790a6b21769273)
1*635a8641SAndroid Build Coastguard Worker // Copyright (C) 2018 The Android Open Source Project
2*635a8641SAndroid Build Coastguard Worker //
3*635a8641SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
4*635a8641SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
5*635a8641SAndroid Build Coastguard Worker // You may obtain a copy of the License at
6*635a8641SAndroid Build Coastguard Worker //
7*635a8641SAndroid Build Coastguard Worker //      http://www.apache.org/licenses/LICENSE-2.0
8*635a8641SAndroid Build Coastguard Worker //
9*635a8641SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
10*635a8641SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
11*635a8641SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*635a8641SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
13*635a8641SAndroid Build Coastguard Worker // limitations under the License.
14*635a8641SAndroid Build Coastguard Worker 
15*635a8641SAndroid Build Coastguard Worker // third_party/ashmem is Android shared memory. Instead of clone it here,
16*635a8641SAndroid Build Coastguard Worker // use cutils/ashmem.h directly.
17*635a8641SAndroid Build Coastguard Worker #include <cutils/ashmem.h>
18*635a8641SAndroid Build Coastguard Worker 
19*635a8641SAndroid Build Coastguard Worker #ifdef __cplusplus
20*635a8641SAndroid Build Coastguard Worker extern "C" {
21*635a8641SAndroid Build Coastguard Worker #endif
22*635a8641SAndroid Build Coastguard Worker 
ashmem_get_prot_region(int fd)23*635a8641SAndroid Build Coastguard Worker inline int ashmem_get_prot_region(int fd) {
24*635a8641SAndroid Build Coastguard Worker   int ret = ashmem_valid(fd);
25*635a8641SAndroid Build Coastguard Worker   if (ret < 0)
26*635a8641SAndroid Build Coastguard Worker     return ret;
27*635a8641SAndroid Build Coastguard Worker   return TEMP_FAILURE_RETRY(ioctl(fd, ASHMEM_GET_PROT_MASK));
28*635a8641SAndroid Build Coastguard Worker }
29*635a8641SAndroid Build Coastguard Worker 
30*635a8641SAndroid Build Coastguard Worker #ifdef __cplusplus
31*635a8641SAndroid Build Coastguard Worker }
32*635a8641SAndroid Build Coastguard Worker #endif
33