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