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 #include "hook.h" 16 #include "thread_private_data_ctl.h" 17 #include "wrapper_log.h" 18 19 #undef CALL_HOOK_API 20 #define CALL_HOOK_API(api, ...) \ 21 do { \ 22 OHOS::GlHookTable const *table = OHOS::ThreadPrivateDataCtl::GetGlHookTable(); \ 23 if (table && table->table2.api) { \ 24 table->table2.api(__VA_ARGS__); \ 25 } else { \ 26 WLOGE("%{public}s is invalid.", #api); \ 27 } \ 28 } while (0); \ 29 } 30 31 #undef CALL_HOOK_API_RET 32 #define CALL_HOOK_API_RET(api, ...) do { \ 33 OHOS::GlHookTable const *table = OHOS::ThreadPrivateDataCtl::GetGlHookTable(); \ 34 if (table && table->table2.api) { \ 35 return table->table2.api(__VA_ARGS__); \ 36 } else { \ 37 WLOGE("%{public}s is invalid.", #api); \ 38 return 0; \ 39 } \ 40 } while (0); \ 41 } 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 "gl2_hook_entries.in" 49 #pragma GCC diagnostic warning "-Wunused-parameter" 50 } 51