Skip to content

Move emscripten_GetProcAddress callers into C #13524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/library_egl.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,6 @@ var LibraryEGL = {
return 0 /* EGL_FALSE */;
},

eglGetProcAddress__deps: ['emscripten_GetProcAddress'],
eglGetProcAddress__proxy: 'sync',
eglGetProcAddress__sig: 'ii',
eglGetProcAddress: function(name_) {
return _emscripten_GetProcAddress(name_);
},

eglReleaseThread__proxy: 'sync',
eglReleaseThread__sig: 'i',
eglReleaseThread: function() {
Expand Down
6 changes: 0 additions & 6 deletions src/library_glfw.js
Original file line number Diff line number Diff line change
Expand Up @@ -1207,12 +1207,6 @@ var LibraryGLFW = {
return (GLFW.extensions.indexOf("GL_" + extension) != -1);
},

glfwGetProcAddress__deps: ['emscripten_GetProcAddress'],
glfwGetProcAddress__sig: 'ii',
glfwGetProcAddress: function(procname) {
return _emscripten_GetProcAddress(procname);
},

glfwSwapInterval__deps: ['emscripten_set_main_loop_timing'],
glfwSwapInterval__sig: 'vi',
glfwSwapInterval: function(interval) {
Expand Down
5 changes: 0 additions & 5 deletions src/library_sdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3450,11 +3450,6 @@ var LibrarySDL = {
return 0;
},

SDL_GL_GetProcAddress__deps: ['emscripten_GetProcAddress'],
SDL_GL_GetProcAddress: function(name_) {
return _emscripten_GetProcAddress(name_);
},

SDL_GL_SwapBuffers__proxy: 'sync',
SDL_GL_SwapBuffers__sig: 'v',
SDL_GL_SwapBuffers: function() {
Expand Down
23 changes: 23 additions & 0 deletions system/lib/gl/libprocaddr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2021 The Emscripten Authors. All rights reserved.
* Emscripten is available under two separate licenses, the MIT license and the
* University of Illinois/NCSA Open Source License. Both these licenses can be
* found in the LICENSE file.
*/

// GL proc address library integration

extern void* emscripten_GetProcAddress(const char *name);

__attribute__((weak)) // SDL2 will link in its own version of this
void* SDL_GL_GetProcAddress(const char* name) {
return emscripten_GetProcAddress(name);
}

void* eglGetProcAddress(const char* name) {
return emscripten_GetProcAddress(name);
}

void* glfwGetProcAddress(const char* name) {
return emscripten_GetProcAddress(name);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not make sense to these to live in their various different libraries?

Is emscripten_GetProcAddress just for GL symbols? I wonder if it should be renamed to reflect that?

Copy link
Member Author

@kripken kripken Feb 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have compiled libraries for them, and adding new ones just for what are basically aliases seemed like overkill. Perhaps we can even just make them aliases in the headers, if you prefer that?

Yes, that function is just for GL symbols. I'm not opposed to renaming it (separate from this PR I assume?)

Copy link
Collaborator

@sbc100 sbc100 Feb 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this now if tests pass.

6 changes: 3 additions & 3 deletions tools/deps_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
deps_info = {
'Mix_LoadWAV_RW': ['fileno'],
'SDL_CreateRGBSurface': ['malloc', 'free'],
'SDL_GL_GetProcAddress': ['emscripten_GetProcAddress'],
'SDL_GL_GetProcAddress': ['malloc'],
'SDL_Init': ['malloc', 'free', 'memset', 'memcpy'],
'SDL_LockSurface': ['malloc', 'free'],
'SDL_OpenAudio': ['malloc', 'free'],
Expand All @@ -77,7 +77,7 @@
'ctime_r': ['_get_tzname', '_get_daylight', '_get_timezone', 'malloc'],
'dladdr': ['malloc'],
'dlerror': ['malloc', 'free'],
'eglGetProcAddress': ['emscripten_GetProcAddress'],
'eglGetProcAddress': ['malloc'],
'eglQueryString': ['malloc'],
'emscripten_GetProcAddress': ['malloc'],
'emscripten_GetAlProcAddress': ['emscripten_GetAlProcAddress'],
Expand Down Expand Up @@ -165,7 +165,7 @@
'glGetStringi': ['malloc'],
'glMapBufferRange': ['malloc'],
'glewInit': ['malloc'],
'glfwGetProcAddress': ['emscripten_GetProcAddress'],
'glfwGetProcAddress': ['malloc'],
'glfwInit': ['malloc', 'free'],
'glfwSleep': ['sleep'],
'gmtime': ['malloc'],
Expand Down
2 changes: 1 addition & 1 deletion tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ class libgl(MTLibrary):
name = 'libgl'

src_dir = ['system', 'lib', 'gl']
src_files = ['gl.c', 'webgl1.c']
src_files = ['gl.c', 'webgl1.c', 'libprocaddr.c']

cflags = ['-Oz']

Expand Down