1 /* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0 */ 2 /* 3 * include/linux/ashmem.h 4 * 5 * Copyright 2008 Google Inc. 6 * Author: Robert Love 7 */ 8 9 #ifndef _LINUX_ASHMEM_H 10 #define _LINUX_ASHMEM_H 11 12 #include <linux/limits.h> 13 #include <linux/ioctl.h> 14 #include <linux/compat.h> 15 16 #include "uapi/ashmem.h" 17 18 /* support of 32bit userspace on 64bit platforms */ 19 #ifdef CONFIG_COMPAT 20 #define COMPAT_ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, compat_size_t) 21 #define COMPAT_ASHMEM_SET_PROT_MASK _IOW(__ASHMEMIOC, 5, unsigned int) 22 #endif 23 24 int is_ashmem_file(struct file *file); 25 size_t get_ashmem_size_by_file(struct file *f); 26 char *get_ashmem_name_by_file(struct file *f); 27 void ashmem_mutex_lock(void); 28 void ashmem_mutex_unlock(void); 29 30 #ifdef CONFIG_PURGEABLE_ASHMEM 31 struct purgeable_ashmem_metadata { 32 char *name; 33 size_t size; 34 int refc; 35 bool purged; 36 bool is_purgeable; 37 unsigned int id; 38 unsigned int create_time; 39 }; 40 41 void ashmem_shrinkall(void); 42 void ashmem_shrink_by_id(const unsigned int ashmem_id, 43 const unsigned int create_time); 44 bool get_purgeable_ashmem_metadata(struct file *f, 45 struct purgeable_ashmem_metadata *pmdata); 46 #endif 47 #endif /* _LINUX_ASHMEM_H */ 48