• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "../hook.h"
17 #include "../thread_private_data_ctl.h"
18 #include "../wrapper_log.h"
19 
20 #undef CALL_HOOK_API
21 #define CALL_HOOK_API(api, ...)                                                         \
22     do {                                                                                \
23         OHOS::GlHookTable const *table = OHOS::ThreadPrivateDataCtl::GetGlHookTable();  \
24         if (table && table->table3.api) {                                               \
25             table->table3.api(__VA_ARGS__);                                             \
26         } else {                                                                        \
27             WLOGE("%{public}s is invalid.", #api);                                      \
28         }                                                                               \
29     } while (0);                                                                        \
30 }
31 
32 #undef CALL_HOOK_API_RET
33 #define CALL_HOOK_API_RET(api, ...) do {                                                \
34         OHOS::GlHookTable const *table = OHOS::ThreadPrivateDataCtl::GetGlHookTable();  \
35         if (table && table->table3.api) {                                               \
36             return table->table3.api(__VA_ARGS__);                                      \
37         } else {                                                                        \
38             WLOGE("%{public}s is invalid.", #api);                                      \
39             return 0;                                                                   \
40         }                                                                               \
41     } while (0);                                                                        \
42 }
43 #undef HOOK_API_ENTRY
44 #define HOOK_API_ENTRY(r, api, ...) r api(__VA_ARGS__) {                                \
45 
46 extern "C" {
47 #pragma GCC diagnostic ignored "-Wunused-parameter"
48 #include "../gl3_hook_entries.in"
49 #pragma GCC diagnostic warning "-Wunused-parameter"
50 }
51