1 /*
2 * Copyright (c) 2023 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 #include "pthread.h"
16
17 #include "purgeable_mem_builder_c.h"
18 #include "purgeable_mem_c.h"
19 #include "ux_page_table_c.h"
20 #include "purgeable_memory.h"
21
22 #undef LOG_TAG
23 #define LOG_TAG "PurgeableMemNDK"
24
25 typedef bool (*OH_PurgeableMemory_ModifyFunc)(void *, size_t, void *);
26 typedef struct PurgMem OH_PurgeableMemory;
27 typedef struct PurgMem PurgMem;
28
OH_PurgeableMemory_Create(size_t size,OH_PurgeableMemory_ModifyFunc func,void * funcPara)29 OH_PurgeableMemory *OH_PurgeableMemory_Create(
30 size_t size, OH_PurgeableMemory_ModifyFunc func, void *funcPara)
31 {
32 return (OH_PurgeableMemory *)PurgMemCreate(size, func, funcPara);
33 }
34
OH_PurgeableMemory_Destroy(OH_PurgeableMemory * purgObj)35 bool OH_PurgeableMemory_Destroy(OH_PurgeableMemory *purgObj)
36 {
37 return PurgMemDestroy((PurgMem *)purgObj);
38 }
39
OH_PurgeableMemory_BeginRead(OH_PurgeableMemory * purgObj)40 bool OH_PurgeableMemory_BeginRead(OH_PurgeableMemory *purgObj)
41 {
42 return PurgMemBeginRead((PurgMem *)purgObj);
43 }
44
OH_PurgeableMemory_EndRead(OH_PurgeableMemory * purgObj)45 void OH_PurgeableMemory_EndRead(OH_PurgeableMemory *purgObj)
46 {
47 PurgMemEndRead((PurgMem *)purgObj);
48 }
49
OH_PurgeableMemory_BeginWrite(OH_PurgeableMemory * purgObj)50 bool OH_PurgeableMemory_BeginWrite(OH_PurgeableMemory *purgObj)
51 {
52 return PurgMemBeginWrite((PurgMem *)purgObj);
53 }
54
OH_PurgeableMemory_EndWrite(OH_PurgeableMemory * purgObj)55 void OH_PurgeableMemory_EndWrite(OH_PurgeableMemory *purgObj)
56 {
57 PurgMemEndWrite((PurgMem *)purgObj);
58 }
59
OH_PurgeableMemory_GetContent(OH_PurgeableMemory * purgObj)60 void *OH_PurgeableMemory_GetContent(OH_PurgeableMemory *purgObj)
61 {
62 return PurgMemGetContent((PurgMem *)purgObj);
63 }
64
OH_PurgeableMemory_ContentSize(OH_PurgeableMemory * purgObj)65 size_t OH_PurgeableMemory_ContentSize(OH_PurgeableMemory *purgObj)
66 {
67 return PurgMemGetContentSize((PurgMem *)purgObj);
68 }
69
OH_PurgeableMemory_AppendModify(OH_PurgeableMemory * purgObj,OH_PurgeableMemory_ModifyFunc func,void * funcPara)70 bool OH_PurgeableMemory_AppendModify(OH_PurgeableMemory *purgObj,
71 OH_PurgeableMemory_ModifyFunc func, void *funcPara)
72 {
73 return PurgMemAppendModify((PurgMem *)purgObj, func, funcPara);
74 }