blob: 9d029dfad41a85cab4e33223776bc4199c937978 [file] [log] [blame]
Peng Xu5f88ac52017-02-24 01:53:10 -08001/*
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#include <android/sharedmem.h>
18#include <cutils/ashmem.h>
19#include <utils/Errors.h>
20
21int ASharedMemory_create(const char *name, size_t size) {
22 if (size == 0) {
23 return android::BAD_VALUE;
24 }
25 return ashmem_create_region(name, size);
26}
27
28size_t ASharedMemory_getSize(int fd) {
29 return ashmem_valid(fd) ? ashmem_get_size_region(fd) : 0;
30}
31
32int ASharedMemory_setProt(int fd, int prot) {
33 return ashmem_set_prot_region(fd, prot);
34}