1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_UTIL_H 17 #define OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_UTIL_H 18 19 #ifdef __cplusplus 20 #if __cplusplus 21 extern "C" { 22 #endif /* End of #if __cplusplus */ 23 #endif /* End of #ifdef __cplusplus */ 24 25 /* 26 * USE_UXPT > 0 means enable uxpt(using uxpt) in libpurgeable, 27 * while USE_UXPT == 0 means not using uxpt, 0 will be used in the following cases: 28 * case 1: if there is no purgeable mem module in kernel. 29 * case 2: if you want close libpurgeable, meanwhile doesn't affect user programs. 30 */ 31 #define USE_UXPT 1 32 33 #define MAP_PURGEABLE 0x04 34 #define MAP_USEREXPTE 0x08 35 36 #define PAGE_SHIFT 12 37 #ifdef PAGE_SIZE 38 #undef PAGE_SIZE 39 #endif 40 #define PAGE_SIZE (1 << PAGE_SHIFT) 41 42 /* 43 * When UXPT is not used, In order not to affect the normal function 44 * of user programs, this lib will provide normal anon memory. So 45 * MAP_PURGEABLE is set to 0x0. 46 */ 47 #if !defined(USE_UXPT) || (USE_UXPT == 0) 48 #undef MAP_PURGEABLE 49 #define MAP_PURGEABLE 0x0 50 #undef MAP_USEREXPTE 51 #define MAP_USEREXPTE 0x0 52 #endif 53 54 #ifdef __cplusplus 55 #if __cplusplus 56 } 57 #endif /* End of #if __cplusplus */ 58 #endif /* End of #ifdef __cplusplus */ 59 60 #endif /* OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_UTIL_H */ 61