1570af302Sopenharmony_ci/*
2570af302Sopenharmony_ci * Copyright (c) Huawei Technologies Co., Ltd. 2020-2023. All rights reserved.
3570af302Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4570af302Sopenharmony_ci * you may not use this file except in compliance with the License.
5570af302Sopenharmony_ci * You may obtain a copy of the License at
6570af302Sopenharmony_ci *
7570af302Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8570af302Sopenharmony_ci *
9570af302Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10570af302Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11570af302Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12570af302Sopenharmony_ci * See the License for the specific language governing permissions and
13570af302Sopenharmony_ci * limitations under the License.
14570af302Sopenharmony_ci */
15570af302Sopenharmony_ci
16570af302Sopenharmony_ci#include <dlfcn.h>
17570af302Sopenharmony_ci#include <iostream>
18570af302Sopenharmony_ci#include "util.h"
19570af302Sopenharmony_ci
20570af302Sopenharmony_ciusing namespace std;
21570af302Sopenharmony_ci
22570af302Sopenharmony_ci#if (!defined(SYSTEM_32_BIT))
23570af302Sopenharmony_cistatic vector<string> syms = {
24570af302Sopenharmony_ci    "eglGetProcAddress",
25570af302Sopenharmony_ci    "eglChooseConfig",
26570af302Sopenharmony_ci    "eglCopyBuffers",
27570af302Sopenharmony_ci    "eglCreateContext",
28570af302Sopenharmony_ci    "eglCreatePbufferSurface",
29570af302Sopenharmony_ci    "eglDestroySurface",
30570af302Sopenharmony_ci    "eglGetConfigs",
31570af302Sopenharmony_ci    "eglGetCurrentSurface",
32570af302Sopenharmony_ci    "eglGetError",
33570af302Sopenharmony_ci    "eglGetProcAddress",
34570af302Sopenharmony_ci    "eglMakeCurrent",
35570af302Sopenharmony_ci    "eglQueryString",
36570af302Sopenharmony_ci    "eglSwapBuffers",
37570af302Sopenharmony_ci    "glGetFloatv",
38570af302Sopenharmony_ci    "glGetLightfv",
39570af302Sopenharmony_ci    "glGetTexEnvfv",
40570af302Sopenharmony_ci    "glLightModelf",
41570af302Sopenharmony_ci    "glLightModelfv",
42570af302Sopenharmony_ci    "glLightf",
43570af302Sopenharmony_ci    "glLightfv",
44570af302Sopenharmony_ci    "glLineWidth",
45570af302Sopenharmony_ci    "glOrthof",
46570af302Sopenharmony_ci    "glPointParameterfv",
47570af302Sopenharmony_ci    "glPolygonOffset",
48570af302Sopenharmony_ci    "glColor4x",
49570af302Sopenharmony_ci    "glCompressedTexImage2D",
50570af302Sopenharmony_ci    "glEnableClientState",
51570af302Sopenharmony_ci    "glFlush",
52570af302Sopenharmony_ci    "glFogxv",
53570af302Sopenharmony_ci    "glGetLightxv",
54570af302Sopenharmony_ci    "glGetTexEnviv",
55570af302Sopenharmony_ci    "glShadeModel",
56570af302Sopenharmony_ci    "glStencilOp",
57570af302Sopenharmony_ci    "glTexEnvi",
58570af302Sopenharmony_ci    "glTexEnvx",
59570af302Sopenharmony_ci    "glTexImage2D",
60570af302Sopenharmony_ci    "glTexParameterx",
61570af302Sopenharmony_ci    "glPointSizePointerOES",
62570af302Sopenharmony_ci    "glEGLImageTargetTexture2DOES",
63570af302Sopenharmony_ci    "glEGLImageTargetRenderbufferStorageOES",
64570af302Sopenharmony_ci    "glBlendEquationSeparateOES",
65570af302Sopenharmony_ci    "glBlendFuncSeparateOES",
66570af302Sopenharmony_ci    "glDrawTexxOES",
67570af302Sopenharmony_ci    "glDrawTexivOES",
68570af302Sopenharmony_ci    "glDrawTexxvOES",
69570af302Sopenharmony_ci    "glDrawTexfvOES",
70570af302Sopenharmony_ci    "glClearColorxOES",
71570af302Sopenharmony_ci    "glFogxvOES",
72570af302Sopenharmony_ci    "glGetClipPlanexOES",
73570af302Sopenharmony_ci    "glMaterialxOES",
74570af302Sopenharmony_ci    "glMultMatrixxOES",
75570af302Sopenharmony_ci    "glNormal3xOES",
76570af302Sopenharmony_ci    "glPointParameterxvOES",
77570af302Sopenharmony_ci    "glTexEnvxOES",
78570af302Sopenharmony_ci    "glTexParameterxOES",
79570af302Sopenharmony_ci    "glTranslatexOES",
80570af302Sopenharmony_ci    "glGetMaterialxvOES",
81570af302Sopenharmony_ci    "glSampleCoveragexOES",
82570af302Sopenharmony_ci    "glBindFramebufferOES",
83570af302Sopenharmony_ci    "glGenFramebuffersOES",
84570af302Sopenharmony_ci    "glFramebufferRenderbufferOES",
85570af302Sopenharmony_ci    "glGetFramebufferAttachmentParameterivOES",
86570af302Sopenharmony_ci    "glGenerateMipmapOES",
87570af302Sopenharmony_ci    "glUnmapBufferOES",
88570af302Sopenharmony_ci    "glCurrentPaletteMatrixOES",
89570af302Sopenharmony_ci    "glLoadPaletteFromModelViewMatrixOES",
90570af302Sopenharmony_ci    "glWeightPointerOES",
91570af302Sopenharmony_ci    "glClearDepthfOES",
92570af302Sopenharmony_ci    "glClipPlanefOES",
93570af302Sopenharmony_ci    "glFrustumfOES",
94570af302Sopenharmony_ci    "glGetClipPlanefOES",
95570af302Sopenharmony_ci    "glTexGenfOES",
96570af302Sopenharmony_ci    "glTexGenfvOES",
97570af302Sopenharmony_ci    "glTexGenivOES",
98570af302Sopenharmony_ci    "glGetTexGenivOES",
99570af302Sopenharmony_ci    "glBindVertexArrayOES",
100570af302Sopenharmony_ci    "glGenVertexArraysOES",
101570af302Sopenharmony_ci    "glDiscardFramebufferEXT",
102570af302Sopenharmony_ci    "glRenderbufferStorageMultisampleEXT",
103570af302Sopenharmony_ci    "glGetnUniformfvEXT",
104570af302Sopenharmony_ci    "glGetnUniformivEXT",
105570af302Sopenharmony_ci    "glTexStorage2DEXT",
106570af302Sopenharmony_ci    "glTexStorage3DEXT",
107570af302Sopenharmony_ci    "glColorMask",
108570af302Sopenharmony_ci    "glCompressedTexImage2D",
109570af302Sopenharmony_ci    "glCompressedTexSubImage2D",
110570af302Sopenharmony_ci    "glCopyTexImage2D",
111570af302Sopenharmony_ci    "glCreateProgram",
112570af302Sopenharmony_ci    "glDrawElements",
113570af302Sopenharmony_ci    "glGenBuffers",
114570af302Sopenharmony_ci    "glGenFramebuffers",
115570af302Sopenharmony_ci    "glGenRenderbuffers",
116570af302Sopenharmony_ci    "glGenTextures",
117570af302Sopenharmony_ci    "glObjectLabelKHR",
118570af302Sopenharmony_ci    "glGetObjectLabelKHR",
119570af302Sopenharmony_ci    "glGetnUniformivKHR",
120570af302Sopenharmony_ci    "glDrawElementsBaseVertexOES",
121570af302Sopenharmony_ci    "glDrawElementsInstancedBaseVertexOES",
122570af302Sopenharmony_ci    "glPrimitiveBoundingBoxOES",
123570af302Sopenharmony_ci    "glMinSampleShadingOES",
124570af302Sopenharmony_ci    "glTexImage3DOES",
125570af302Sopenharmony_ci    "glTexSubImage3DOES",
126570af302Sopenharmony_ci    "glCompressedTexImage3DOES",
127570af302Sopenharmony_ci    "glCompressedTexSubImage3DOES",
128570af302Sopenharmony_ci    "glTexParameterIivOES",
129570af302Sopenharmony_ci    "glGetTexParameterIivOES",
130570af302Sopenharmony_ci    "glGetTexParameterIuivOES",
131570af302Sopenharmony_ci    "glBindVertexArrayOES",
132570af302Sopenharmony_ci    "glEGLImageTargetTexStorageEXT",
133570af302Sopenharmony_ci    "glBufferStorageEXT",
134570af302Sopenharmony_ci    "glCopyImageSubDataEXT",
135570af302Sopenharmony_ci    "glDiscardFramebufferEXT",
136570af302Sopenharmony_ci    "glGenQueriesEXT",
137570af302Sopenharmony_ci    "glDeleteQueriesEXT",
138570af302Sopenharmony_ci    "glQueryCounterEXT",
139570af302Sopenharmony_ci    "glGetQueryObjectivEXT",
140570af302Sopenharmony_ci    "glGetQueryObjectuivEXT",
141570af302Sopenharmony_ci    "glGetQueryObjecti64vEXT",
142570af302Sopenharmony_ci    "glGetQueryObjectui64vEXT",
143570af302Sopenharmony_ci    "glEnableiEXT",
144570af302Sopenharmony_ci    "glDisableiEXT",
145570af302Sopenharmony_ci    "glBlendEquationiEXT",
146570af302Sopenharmony_ci    "glColorMaskiEXT",
147570af302Sopenharmony_ci    "glIsEnablediEXT",
148570af302Sopenharmony_ci    "glRenderbufferStorageMultisampleEXT",
149570af302Sopenharmony_ci    "glGetGraphicsResetStatusEXT",
150570af302Sopenharmony_ci    "glGetnUniformfvEXT",
151570af302Sopenharmony_ci    "glGetnUniformivEXT",
152570af302Sopenharmony_ci    "glPatchParameteriEXT",
153570af302Sopenharmony_ci    "glTexParameterIuivEXT",
154570af302Sopenharmony_ci    "glGetSamplerParameterIivEXT",
155570af302Sopenharmony_ci    "glTexBufferEXT",
156570af302Sopenharmony_ci    "glTexBufferRangeEXT",
157570af302Sopenharmony_ci    "glTexStorage2DEXT",
158570af302Sopenharmony_ci    "glTexStorage3DEXT",
159570af302Sopenharmony_ci    "glFramebufferTextureMultiviewOVR",
160570af302Sopenharmony_ci    "glFramebufferTextureMultisampleMultiviewOVR",
161570af302Sopenharmony_ci    "glBindBuffer",
162570af302Sopenharmony_ci    "glBufferData",
163570af302Sopenharmony_ci    "glCheckFramebufferStatus",
164570af302Sopenharmony_ci    "glClear",
165570af302Sopenharmony_ci    "glClearColor",
166570af302Sopenharmony_ci    "glClearDepthf",
167570af302Sopenharmony_ci    "glClearStencil",
168570af302Sopenharmony_ci    "glCompileShader",
169570af302Sopenharmony_ci    "glCompressedTexImage2D",
170570af302Sopenharmony_ci    "glCompressedTexSubImage2D",
171570af302Sopenharmony_ci    "glCopyTexImage2D",
172570af302Sopenharmony_ci    "glCopyTexSubImage2D",
173570af302Sopenharmony_ci    "glCreateProgram",
174570af302Sopenharmony_ci    "glCreateShader",
175570af302Sopenharmony_ci    "glDeleteBuffers",
176570af302Sopenharmony_ci    "glDeleteFramebuffers",
177570af302Sopenharmony_ci    "glDeleteProgram",
178570af302Sopenharmony_ci    "glDeleteShader",
179570af302Sopenharmony_ci    "glDeleteTextures",
180570af302Sopenharmony_ci    "glDepthFunc",
181570af302Sopenharmony_ci    "glDepthRangef",
182570af302Sopenharmony_ci    "glDetachShader",
183570af302Sopenharmony_ci    "glDisable",
184570af302Sopenharmony_ci    "glDrawArrays",
185570af302Sopenharmony_ci    "glDrawElements",
186570af302Sopenharmony_ci    "glEnable",
187570af302Sopenharmony_ci    "glEnableVertexAttribArray",
188570af302Sopenharmony_ci    "glFlush",
189570af302Sopenharmony_ci    "glFramebufferRenderbuffer",
190570af302Sopenharmony_ci    "glFrontFace",
191570af302Sopenharmony_ci    "glGenBuffers",
192570af302Sopenharmony_ci    "glGenTextures",
193570af302Sopenharmony_ci    "glGetActiveUniform",
194570af302Sopenharmony_ci    "glGetAttachedShaders",
195570af302Sopenharmony_ci    "glGetError",
196570af302Sopenharmony_ci    "glGetFramebufferAttachmentParameteriv",
197570af302Sopenharmony_ci    "glGetIntegerv",
198570af302Sopenharmony_ci    "glGetProgramiv",
199570af302Sopenharmony_ci    "glGetRenderbufferParameteriv",
200570af302Sopenharmony_ci    "glGetShaderiv",
201570af302Sopenharmony_ci    "glGetShaderPrecisionFormat",
202570af302Sopenharmony_ci    "glGetShaderSource",
203570af302Sopenharmony_ci    "glGetString",
204570af302Sopenharmony_ci    "glGetTexParameterfv",
205570af302Sopenharmony_ci    "glGetUniformfv",
206570af302Sopenharmony_ci    "glGetUniformiv",
207570af302Sopenharmony_ci    "glGetUniformLocation",
208570af302Sopenharmony_ci    "glGetVertexAttribiv",
209570af302Sopenharmony_ci    "glGetVertexAttribPointerv",
210570af302Sopenharmony_ci    "glVertexAttribI4iv",
211570af302Sopenharmony_ci    "glGetUniformuiv",
212570af302Sopenharmony_ci    "glClearBufferfv",
213570af302Sopenharmony_ci    "glGetStringi",
214570af302Sopenharmony_ci    "glCopyBufferSubData",
215570af302Sopenharmony_ci    "glGetUniformIndices",
216570af302Sopenharmony_ci    "glGetActiveUniformsiv",
217570af302Sopenharmony_ci    "glGetUniformBlockIndex",
218570af302Sopenharmony_ci    "glIsSync",
219570af302Sopenharmony_ci    "glClientWaitSync",
220570af302Sopenharmony_ci    "glWaitSync",
221570af302Sopenharmony_ci    "glGetInteger64v",
222570af302Sopenharmony_ci    "glGetInteger64i_v",
223570af302Sopenharmony_ci    "glGetBufferParameteri64v",
224570af302Sopenharmony_ci    "glGetSamplerParameteriv",
225570af302Sopenharmony_ci    "glInvalidateSubFramebuffer",
226570af302Sopenharmony_ci    "glTexStorage3D",
227570af302Sopenharmony_ci    "glDispatchCompute",
228570af302Sopenharmony_ci    "glDispatchComputeIndirect",
229570af302Sopenharmony_ci    "glDrawElementsIndirect",
230570af302Sopenharmony_ci    "glFramebufferParameteri",
231570af302Sopenharmony_ci    "glGetProgramInterfaceiv",
232570af302Sopenharmony_ci    "glGetProgramResourceIndex",
233570af302Sopenharmony_ci    "glGetProgramResourceiv",
234570af302Sopenharmony_ci    "glUseProgramStages",
235570af302Sopenharmony_ci    "glActiveShaderProgram",
236570af302Sopenharmony_ci    "glBindProgramPipeline",
237570af302Sopenharmony_ci    "glGetPointerv",
238570af302Sopenharmony_ci    "glBlendEquationi",
239570af302Sopenharmony_ci    "glBlendFuncSeparatei",
240570af302Sopenharmony_ci    "glDrawElementsBaseVertex",
241570af302Sopenharmony_ci    "glDrawElementsInstancedBaseVertex",
242570af302Sopenharmony_ci    "glPrimitiveBoundingBox",
243570af302Sopenharmony_ci    "glGetGraphicsResetStatus",
244570af302Sopenharmony_ci    "glGetnUniformiv",
245570af302Sopenharmony_ci    "glGetnUniformuiv",
246570af302Sopenharmony_ci    "glPatchParameteri",
247570af302Sopenharmony_ci    "glTexParameterIuiv",
248570af302Sopenharmony_ci    "glGetTexParameterIiv",
249570af302Sopenharmony_ci    "glSamplerParameterIiv",
250570af302Sopenharmony_ci    "glBlendBarrierKHR",
251570af302Sopenharmony_ci    "glDebugMessageControlKHR",
252570af302Sopenharmony_ci    "glDebugMessageCallbackKHR",
253570af302Sopenharmony_ci    "glGetDebugMessageLogKHR",
254570af302Sopenharmony_ci    "glPopDebugGroupKHR",
255570af302Sopenharmony_ci    "glGetObjectLabelKHR",
256570af302Sopenharmony_ci    "glGetObjectPtrLabelKHR",
257570af302Sopenharmony_ci    "glGetPointervKHR",
258570af302Sopenharmony_ci    "glGetGraphicsResetStatusKHR",
259570af302Sopenharmony_ci    "glReadnPixelsKHR",
260570af302Sopenharmony_ci    "glGetnUniformfvKHR",
261570af302Sopenharmony_ci    "glCopyImageSubDataOES",
262570af302Sopenharmony_ci    "glDisableiOES",
263570af302Sopenharmony_ci    "glBlendEquationiOES",
264570af302Sopenharmony_ci    "glIsQueryEXT",
265570af302Sopenharmony_ci    "glGetQueryivEXT",
266570af302Sopenharmony_ci    "glEnableiEXT",
267570af302Sopenharmony_ci    "glBlendEquationSeparateiEXT",
268570af302Sopenharmony_ci    "glBlendFunciEXT",
269570af302Sopenharmony_ci    "glTexStorage2DEXT",
270570af302Sopenharmony_ci    "eglChooseConfig",
271570af302Sopenharmony_ci    "eglCopyBuffers",
272570af302Sopenharmony_ci    "eglCreateContext",
273570af302Sopenharmony_ci    "eglCreatePbufferSurface",
274570af302Sopenharmony_ci    "eglCreatePixmapSurface",
275570af302Sopenharmony_ci    "eglCreateWindowSurface",
276570af302Sopenharmony_ci    "eglDestroyContext",
277570af302Sopenharmony_ci    "eglDestroySurface",
278570af302Sopenharmony_ci    "eglGetConfigAttrib",
279570af302Sopenharmony_ci    "eglGetConfigs",
280570af302Sopenharmony_ci    "eglGetCurrentDisplay",
281570af302Sopenharmony_ci    "eglGetCurrentSurface",
282570af302Sopenharmony_ci    "eglGetDisplay",
283570af302Sopenharmony_ci    "eglGetError",
284570af302Sopenharmony_ci    "eglInitialize",
285570af302Sopenharmony_ci    "eglMakeCurrent",
286570af302Sopenharmony_ci    "eglQueryContext",
287570af302Sopenharmony_ci    "eglQueryString",
288570af302Sopenharmony_ci    "eglQuerySurface",
289570af302Sopenharmony_ci    "eglSwapBuffers",
290570af302Sopenharmony_ci    "eglTerminate",
291570af302Sopenharmony_ci    "eglWaitGL",
292570af302Sopenharmony_ci    "eglWaitNative",
293570af302Sopenharmony_ci    "eglBindTexImage",
294570af302Sopenharmony_ci    "eglReleaseTexImage",
295570af302Sopenharmony_ci    "eglSurfaceAttrib",
296570af302Sopenharmony_ci    "eglSwapInterval",
297570af302Sopenharmony_ci    "eglBindAPI",
298570af302Sopenharmony_ci    "eglCreatePbufferFromClientBuffer",
299570af302Sopenharmony_ci    "eglReleaseThread",
300570af302Sopenharmony_ci    "eglGetCurrentContext",
301570af302Sopenharmony_ci    "glClearColor",
302570af302Sopenharmony_ci    "glClearStencil",
303570af302Sopenharmony_ci    "glColorMask",
304570af302Sopenharmony_ci    "glCompileShader",
305570af302Sopenharmony_ci    "glCompressedTexImage2D",
306570af302Sopenharmony_ci    "glCompressedTexSubImage2D",
307570af302Sopenharmony_ci    "glDepthFunc",
308570af302Sopenharmony_ci    "glDepthRangef",
309570af302Sopenharmony_ci    "glDetachShader",
310570af302Sopenharmony_ci    "glDisableVertexAttribArray",
311570af302Sopenharmony_ci    "glDrawArrays",
312570af302Sopenharmony_ci    "glDrawElements",
313570af302Sopenharmony_ci    "glEnable",
314570af302Sopenharmony_ci    "glEnableVertexAttribArray",
315570af302Sopenharmony_ci    "glFinish",
316570af302Sopenharmony_ci    "glFlush",
317570af302Sopenharmony_ci    "glGetBufferParameteriv",
318570af302Sopenharmony_ci    "glGetFramebufferAttachmentParameteriv",
319570af302Sopenharmony_ci    "glIsBuffer",
320570af302Sopenharmony_ci    "glIsFramebuffer",
321570af302Sopenharmony_ci    "glIsRenderbuffer",
322570af302Sopenharmony_ci    "glIsShader",
323570af302Sopenharmony_ci    "glIsTexture",
324570af302Sopenharmony_ci    "glLineWidth",
325570af302Sopenharmony_ci    "glLinkProgram",
326570af302Sopenharmony_ci    "glPolygonOffset",
327570af302Sopenharmony_ci    "glReadPixels",
328570af302Sopenharmony_ci    "glReleaseShaderCompiler",
329570af302Sopenharmony_ci    "glRenderbufferStorage",
330570af302Sopenharmony_ci    "glSampleCoverage",
331570af302Sopenharmony_ci    "glScissor",
332570af302Sopenharmony_ci    "glShaderSource",
333570af302Sopenharmony_ci    "glStencilFunc",
334570af302Sopenharmony_ci    "glStencilMask",
335570af302Sopenharmony_ci    "glStencilMaskSeparate",
336570af302Sopenharmony_ci    "glStencilOp",
337570af302Sopenharmony_ci    "glStencilOpSeparate",
338570af302Sopenharmony_ci    "glTexImage2D",
339570af302Sopenharmony_ci    "glTexParameterf",
340570af302Sopenharmony_ci    "glUniform2f",
341570af302Sopenharmony_ci    "glUniform2i",
342570af302Sopenharmony_ci    "glUniform3f",
343570af302Sopenharmony_ci    "glUniform3i",
344570af302Sopenharmony_ci    "glUniform4i",
345570af302Sopenharmony_ci    "glUniformMatrix2fv",
346570af302Sopenharmony_ci    "glUniformMatrix4fv",
347570af302Sopenharmony_ci    "glUseProgram",
348570af302Sopenharmony_ci    "glValidateProgram",
349570af302Sopenharmony_ci    "glVertexAttrib1f",
350570af302Sopenharmony_ci    "glVertexAttrib1fv",
351570af302Sopenharmony_ci    "glVertexAttrib2f",
352570af302Sopenharmony_ci    "glVertexAttrib2fv",
353570af302Sopenharmony_ci    "glVertexAttrib3fv",
354570af302Sopenharmony_ci    "glVertexAttrib4f",
355570af302Sopenharmony_ci    "glVertexAttrib4fv",
356570af302Sopenharmony_ci    "glViewport",
357570af302Sopenharmony_ci    "glBufferStorageEXT",
358570af302Sopenharmony_ci    "glDiscardFramebufferEXT",
359570af302Sopenharmony_ci    "glGenQueriesEXT",
360570af302Sopenharmony_ci    "glDeleteQueriesEXT",
361570af302Sopenharmony_ci    "glIsQueryEXT",
362570af302Sopenharmony_ci    "glBeginQueryEXT",
363570af302Sopenharmony_ci    "glEndQueryEXT",
364570af302Sopenharmony_ci    "glQueryCounterEXT",
365570af302Sopenharmony_ci    "glGetQueryivEXT",
366570af302Sopenharmony_ci    "glGetQueryObjectivEXT",
367570af302Sopenharmony_ci    "glGetQueryObjectuivEXT",
368570af302Sopenharmony_ci    "glGetQueryObjecti64vEXT",
369570af302Sopenharmony_ci    "glGetQueryObjectui64vEXT",
370570af302Sopenharmony_ci    "glEnableiEXT",
371570af302Sopenharmony_ci    "glDisableiEXT",
372570af302Sopenharmony_ci    "glBlendEquationiEXT",
373570af302Sopenharmony_ci    "glBlendEquationSeparateiEXT",
374570af302Sopenharmony_ci    "glBlendFunciEXT",
375570af302Sopenharmony_ci    "glBlendFuncSeparateiEXT",
376570af302Sopenharmony_ci    "glColorMaskiEXT",
377570af302Sopenharmony_ci    "glIsEnablediEXT",
378570af302Sopenharmony_ci    "glDrawElementsBaseVertexEXT",
379570af302Sopenharmony_ci    "glDrawRangeElementsBaseVertexEXT",
380570af302Sopenharmony_ci    "glDrawElementsInstancedBaseVertexEXT",
381570af302Sopenharmony_ci    "glBufferStorageExternalEXT",
382570af302Sopenharmony_ci    "glFramebufferTextureEXT",
383570af302Sopenharmony_ci    "glRenderbufferStorageMultisampleEXT",
384570af302Sopenharmony_ci    "glPrimitiveBoundingBoxEXT",
385570af302Sopenharmony_ci    "glGetSamplerParameterIivEXT",
386570af302Sopenharmony_ci    "glGetSamplerParameterIuivEXT",
387570af302Sopenharmony_ci    "glTexBufferEXT",
388570af302Sopenharmony_ci    "glTexBufferRangeEXT",
389570af302Sopenharmony_ci    "glTexStorage2DEXT",
390570af302Sopenharmony_ci    "glTexStorage3DEXT",
391570af302Sopenharmony_ci    "glDebugMessageControlKHR",
392570af302Sopenharmony_ci    "glDebugMessageInsertKHR",
393570af302Sopenharmony_ci    "glGetObjectLabelKHR",
394570af302Sopenharmony_ci    "glObjectPtrLabelKHR",
395570af302Sopenharmony_ci    "glEGLImageTargetTexture2DOES",
396570af302Sopenharmony_ci    "glEGLImageTargetRenderbufferStorageOES",
397570af302Sopenharmony_ci    "glCopyImageSubDataOES",
398570af302Sopenharmony_ci    "glEnableiOES",
399570af302Sopenharmony_ci    "glDisableiOES",
400570af302Sopenharmony_ci    "glBlendEquationiOES",
401570af302Sopenharmony_ci    "glBlendEquationSeparateiOES",
402570af302Sopenharmony_ci    "glBlendFunciOES",
403570af302Sopenharmony_ci    "glBlendFuncSeparateiOES",
404570af302Sopenharmony_ci    "glColorMaskiOES",
405570af302Sopenharmony_ci    "glIsEnablediOES",
406570af302Sopenharmony_ci    "glDrawElementsBaseVertexOES",
407570af302Sopenharmony_ci    "glDrawRangeElementsBaseVertexOES",
408570af302Sopenharmony_ci    "glDrawElementsInstancedBaseVertexOES",
409570af302Sopenharmony_ci    "glFramebufferTextureOES",
410570af302Sopenharmony_ci    "glGetProgramBinaryOES",
411570af302Sopenharmony_ci    "glProgramBinaryOES",
412570af302Sopenharmony_ci    "glUnmapBufferOES",
413570af302Sopenharmony_ci    "glGetBufferPointervOES",
414570af302Sopenharmony_ci    "glPrimitiveBoundingBoxOES",
415570af302Sopenharmony_ci    "glCopyTexSubImage3DOES",
416570af302Sopenharmony_ci    "glCompressedTexSubImage3DOES",
417570af302Sopenharmony_ci    "glTexParameterIuivOES",
418570af302Sopenharmony_ci    "glGetTexParameterIivOES",
419570af302Sopenharmony_ci    "glGetTexParameterIuivOES",
420570af302Sopenharmony_ci    "glSamplerParameterIivOES",
421570af302Sopenharmony_ci    "glSamplerParameterIuivOES",
422570af302Sopenharmony_ci    "glGetSamplerParameterIivOES",
423570af302Sopenharmony_ci    "glGetSamplerParameterIuivOES",
424570af302Sopenharmony_ci    "glTexBufferOES",
425570af302Sopenharmony_ci    "glTexBufferRangeOES",
426570af302Sopenharmony_ci    "glTexStorage3DMultisampleOES",
427570af302Sopenharmony_ci    "glBindVertexArrayOES",
428570af302Sopenharmony_ci    "glDeleteVertexArraysOES",
429570af302Sopenharmony_ci    "glGenVertexArraysOES",
430570af302Sopenharmony_ci    "glIsVertexArrayOES",
431570af302Sopenharmony_ci    "glFramebufferTextureMultiviewOVR",
432570af302Sopenharmony_ci    "glDrawRangeElements",
433570af302Sopenharmony_ci    "glTexSubImage3D",
434570af302Sopenharmony_ci    "glCopyTexSubImage3D",
435570af302Sopenharmony_ci    "glCompressedTexSubImage3D",
436570af302Sopenharmony_ci    "glGenQueries",
437570af302Sopenharmony_ci    "glGetBufferPointerv",
438570af302Sopenharmony_ci    "glBlitFramebuffer",
439570af302Sopenharmony_ci    "glGenVertexArrays",
440570af302Sopenharmony_ci    "glIsVertexArray",
441570af302Sopenharmony_ci    "glGetIntegeri_v",
442570af302Sopenharmony_ci    "glVertexAttribI4i",
443570af302Sopenharmony_ci    "glVertexAttribI4iv",
444570af302Sopenharmony_ci    "glClearBufferiv",
445570af302Sopenharmony_ci    "glClearBufferfv",
446570af302Sopenharmony_ci    "glClearBufferfi",
447570af302Sopenharmony_ci    "glGetStringi",
448570af302Sopenharmony_ci    "glGetUniformIndices",
449570af302Sopenharmony_ci    "glGetActiveUniformsiv",
450570af302Sopenharmony_ci    "glWaitSync",
451570af302Sopenharmony_ci    "glGetInteger64v",
452570af302Sopenharmony_ci    "glDeleteTransformFeedbacks",
453570af302Sopenharmony_ci    "glIsTransformFeedback",
454570af302Sopenharmony_ci    "glInvalidateSubFramebuffer",
455570af302Sopenharmony_ci    "glGetInternalformativ",
456570af302Sopenharmony_ci    "glGetFramebufferParameteriv",
457570af302Sopenharmony_ci    "glProgramUniform4f",
458570af302Sopenharmony_ci    "glProgramUniform2iv",
459570af302Sopenharmony_ci    "glProgramUniform4iv",
460570af302Sopenharmony_ci    "glProgramUniform2uiv",
461570af302Sopenharmony_ci    "glProgramUniform3uiv",
462570af302Sopenharmony_ci    "glProgramUniform4uiv",
463570af302Sopenharmony_ci    "glProgramUniform2fv",
464570af302Sopenharmony_ci    "glProgramUniform4fv",
465570af302Sopenharmony_ci    "glProgramUniformMatrix2fv",
466570af302Sopenharmony_ci    "glProgramUniformMatrix3fv",
467570af302Sopenharmony_ci    "glProgramUniformMatrix2x3fv",
468570af302Sopenharmony_ci    "glProgramUniformMatrix3x2fv",
469570af302Sopenharmony_ci    "glProgramUniformMatrix2x4fv",
470570af302Sopenharmony_ci    "glProgramUniformMatrix4x2fv",
471570af302Sopenharmony_ci    "glProgramUniformMatrix3x4fv",
472570af302Sopenharmony_ci    "glProgramUniformMatrix4x3fv",
473570af302Sopenharmony_ci    "glValidateProgramPipeline",
474570af302Sopenharmony_ci    "glGetProgramPipelineInfoLog",
475570af302Sopenharmony_ci    "glBindImageTexture",
476570af302Sopenharmony_ci    "glVertexAttribBinding",
477570af302Sopenharmony_ci    "glBlendBarrier",
478570af302Sopenharmony_ci    "glDebugMessageControl",
479570af302Sopenharmony_ci    "glDebugMessageInsert",
480570af302Sopenharmony_ci    "glDebugMessageCallback",
481570af302Sopenharmony_ci    "glGetDebugMessageLog",
482570af302Sopenharmony_ci    "glPushDebugGroup",
483570af302Sopenharmony_ci    "glPopDebugGroup",
484570af302Sopenharmony_ci    "glObjectLabel",
485570af302Sopenharmony_ci    "glGetObjectPtrLabel",
486570af302Sopenharmony_ci    "glEnablei",
487570af302Sopenharmony_ci    "glBlendEquationi",
488570af302Sopenharmony_ci    "glBlendFunci",
489570af302Sopenharmony_ci    "glGetnUniformuiv",
490570af302Sopenharmony_ci    "glPatchParameteri",
491570af302Sopenharmony_ci    "glTexParameterIiv",
492570af302Sopenharmony_ci    "glGetTexParameterIiv",
493570af302Sopenharmony_ci    "glGetTexParameterIuiv",
494570af302Sopenharmony_ci    "glSamplerParameterIiv",
495570af302Sopenharmony_ci};
496570af302Sopenharmony_ci
497570af302Sopenharmony_cistatic void DoDlsym(void *handle)
498570af302Sopenharmony_ci{
499570af302Sopenharmony_ci    for (auto &s :syms) {
500570af302Sopenharmony_ci        void *res = dlsym(handle, s.c_str());
501570af302Sopenharmony_ci        if (res == nullptr) {
502570af302Sopenharmony_ci            printf("dlsym failed: %s.n", dlerror());
503570af302Sopenharmony_ci            exit(-1);
504570af302Sopenharmony_ci        }
505570af302Sopenharmony_ci    }
506570af302Sopenharmony_ci}
507570af302Sopenharmony_ci
508570af302Sopenharmony_cistatic void Bm_function_dlsym_libGLES_mali(benchmark::State &state)
509570af302Sopenharmony_ci{
510570af302Sopenharmony_ci    void *handle = dlopen(LIBGLES_MALI_PATH, RTLD_LAZY);
511570af302Sopenharmony_ci    if (handle == nullptr) {
512570af302Sopenharmony_ci        printf("dlopen %s failed: %s.n", LIBGLES_MALI_PATH, dlerror());
513570af302Sopenharmony_ci        exit(-1);
514570af302Sopenharmony_ci    }
515570af302Sopenharmony_ci    for (auto _ : state) {
516570af302Sopenharmony_ci        DoDlsym(handle);
517570af302Sopenharmony_ci    }
518570af302Sopenharmony_ci}
519570af302Sopenharmony_ci
520570af302Sopenharmony_cistatic void Bm_function_dlclose(benchmark::State &state)
521570af302Sopenharmony_ci{
522570af302Sopenharmony_ci    const char* libace = "libace.z.so";
523570af302Sopenharmony_ci    void *handle;
524570af302Sopenharmony_ci    for (auto _ : state) {
525570af302Sopenharmony_ci        state.PauseTiming();
526570af302Sopenharmony_ci        handle = dlopen(libace, RTLD_LAZY);
527570af302Sopenharmony_ci        if (handle == nullptr) {
528570af302Sopenharmony_ci            printf("dlopen %s failed: %s.n", libace, dlerror());
529570af302Sopenharmony_ci            exit(-1);
530570af302Sopenharmony_ci        }
531570af302Sopenharmony_ci        state.ResumeTiming();
532570af302Sopenharmony_ci        dlclose(handle);
533570af302Sopenharmony_ci    }
534570af302Sopenharmony_ci}
535570af302Sopenharmony_ciMUSL_BENCHMARK(Bm_function_dlsym_libGLES_mali);
536570af302Sopenharmony_ciMUSL_BENCHMARK(Bm_function_dlclose);
537570af302Sopenharmony_ci#endif
538