summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2017-01-24 17:43:59 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2017-01-25 12:43:17 +0000
commit7a06803465dd07e152de1b30763d6bea0d3fcc93 (patch)
treeca0a4b11d4d107acd32cf39bce7fe4f497303ad0 /src
parent0625a74d69f762df8d411bc0451927424aee1f2c (diff)
downloadlibepoxy-7a06803465dd07e152de1b30763d6bea0d3fcc93.tar.gz
Improve consistency of the symbol visibility
To avoid a symbols file on Windows, Epoxy annotates all the publicly visible symbols directly in the source, but uses the default symbol visibility everywhere else. This means that only some symbols are annotated as `EPOXY_IMPORTEXPORT`, and generally only on Windows. Additionally, Epoxy has a private 'PUBLIC' pre-processor macro for internal use, which duplicates the `EPOXY_IMPORTEXPORT` but contains more logic to detect GCC, in case we're building with GCC on Windows. This would be enough, except that EGL is also available on Windows, which means we'd have to annotate the exported `epoxy_*` API inside epoxy/egl.h as well. At that point, though, we should probably avoid any confusion, and adopt a single symbol visibility policy across the board. This requires some surgery of the generated and common dispatch sources, but cuts down the overall complexity: - there is only one annotation, `EPOXY_PUBLIC`, used everywhere - the annotation detection is done at Epoxy configuration time - only annotated symbols are public, on every platform - annotated symbols are immediately visible from the header
Diffstat (limited to 'src')
-rw-r--r--src/dispatch_common.c10
-rw-r--r--src/dispatch_common.h16
-rw-r--r--src/dispatch_egl.c4
-rw-r--r--src/dispatch_glx.c4
-rw-r--r--src/dispatch_wgl.c12
-rwxr-xr-xsrc/gen_dispatch.py16
-rw-r--r--src/meson.build2
7 files changed, 27 insertions, 37 deletions
diff --git a/src/dispatch_common.c b/src/dispatch_common.c
index ab1fb92..374f6d5 100644
--- a/src/dispatch_common.c
+++ b/src/dispatch_common.c
@@ -269,7 +269,7 @@ do_dlsym(void **handle, const char *lib_name, const char *name,
return result;
}
-PUBLIC bool
+bool
epoxy_is_desktop_gl(void)
{
const char *es_prefix = "OpenGL ES";
@@ -333,7 +333,7 @@ epoxy_internal_gl_version(int error_version)
return 10 * major + minor;
}
-PUBLIC int
+int
epoxy_gl_version(void)
{
return epoxy_internal_gl_version(0);
@@ -459,7 +459,7 @@ epoxy_current_context_is_glx(void)
* \sa epoxy_has_egl_extension()
* \sa epoxy_has_glx_extension()
*/
-PUBLIC bool
+bool
epoxy_has_gl_extension(const char *ext)
{
return epoxy_internal_has_gl_extension(ext, false);
@@ -698,5 +698,5 @@ WRAPPER(epoxy_glEnd)(void)
#endif
}
-PUBLIC PFNGLBEGINPROC epoxy_glBegin = epoxy_glBegin_wrapped;
-PUBLIC PFNGLENDPROC epoxy_glEnd = epoxy_glEnd_wrapped;
+PFNGLBEGINPROC epoxy_glBegin = epoxy_glBegin_wrapped;
+PFNGLENDPROC epoxy_glEnd = epoxy_glEnd_wrapped;
diff --git a/src/dispatch_common.h b/src/dispatch_common.h
index 52743a6..40d4bbc 100644
--- a/src/dispatch_common.h
+++ b/src/dispatch_common.h
@@ -21,28 +21,26 @@
* IN THE SOFTWARE.
*/
+#include "config.h"
+
#include <stdbool.h>
#ifdef _WIN32
#define PLATFORM_HAS_EGL 0
#define PLATFORM_HAS_GLX 0
#define PLATFORM_HAS_WGL 1
-#define EPOXY_IMPORTEXPORT __declspec(dllexport)
#elif defined(__APPLE__)
#define PLATFORM_HAS_EGL 0
#define PLATFORM_HAS_GLX 0
#define PLATFORM_HAS_WGL 0
-#define EPOXY_IMPORTEXPORT
#elif defined(ANDROID)
#define PLATFORM_HAS_EGL 1
#define PLATFORM_HAS_GLX 0
#define PLATFORM_HAS_WGL 0
-#define EPOXY_IMPORTEXPORT
#else
#define PLATFORM_HAS_EGL 1
#define PLATFORM_HAS_GLX 1
#define PLATFORM_HAS_WGL 0
-#define EPOXY_IMPORTEXPORT
#endif
#include "epoxy/gl.h"
@@ -56,16 +54,6 @@
#include "epoxy/wgl.h"
#endif
-#ifndef PUBLIC
-# ifdef _WIN32
-# define PUBLIC __declspec(dllexport)
-# elif (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
-# define PUBLIC __attribute__((visibility("default")))
-# else
-# define PUBLIC
-# endif
-#endif
-
#if defined(__GNUC__)
#define PACKED __attribute__((__packed__))
#define ENDPACKED
diff --git a/src/dispatch_egl.c b/src/dispatch_egl.c
index b42aacd..d1dc53c 100644
--- a/src/dispatch_egl.c
+++ b/src/dispatch_egl.c
@@ -38,7 +38,7 @@ epoxy_conservative_egl_version(void)
return epoxy_egl_version(dpy);
}
-PUBLIC int
+int
epoxy_egl_version(EGLDisplay dpy)
{
int major, minor;
@@ -57,7 +57,7 @@ epoxy_conservative_has_egl_extension(const char *ext)
return epoxy_has_egl_extension(eglGetCurrentDisplay(), ext);
}
-PUBLIC bool
+bool
epoxy_has_egl_extension(EGLDisplay dpy, const char *ext)
{
return epoxy_extension_in_string(eglQueryString(dpy, EGL_EXTENSIONS), ext) || epoxy_extension_in_string(eglQueryString(NULL, EGL_EXTENSIONS), ext);
diff --git a/src/dispatch_glx.c b/src/dispatch_glx.c
index 9e4cef6..9396f1c 100644
--- a/src/dispatch_glx.c
+++ b/src/dispatch_glx.c
@@ -47,7 +47,7 @@ epoxy_conservative_glx_version(void)
return epoxy_glx_version(dpy, screen);
}
-PUBLIC int
+int
epoxy_glx_version(Display *dpy, int screen)
{
int server_major, server_minor;
@@ -98,7 +98,7 @@ epoxy_conservative_has_glx_extension(const char *ext)
return epoxy_has_glx_extension(dpy, screen, ext);
}
-PUBLIC bool
+bool
epoxy_has_glx_extension(Display *dpy, int screen, const char *ext)
{
/* No, you can't just use glXGetClientString or
diff --git a/src/dispatch_wgl.c b/src/dispatch_wgl.c
index bfe9bb1..fe5379d 100644
--- a/src/dispatch_wgl.c
+++ b/src/dispatch_wgl.c
@@ -46,7 +46,7 @@ epoxy_conservative_has_wgl_extension(const char *ext)
return epoxy_has_wgl_extension(hdc, ext);
}
-PUBLIC bool
+bool
epoxy_has_wgl_extension(HDC hdc, const char *ext)
{
PFNWGLGETEXTENSIONSSTRINGARBPROC getext;
@@ -72,7 +72,7 @@ epoxy_has_wgl_extension(HDC hdc, const char *ext)
* table per context and reuse it when the context is made current
* again.
*/
-PUBLIC void
+void
epoxy_handle_external_wglMakeCurrent(void)
{
if (!first_context_current) {
@@ -190,7 +190,7 @@ WRAPPER(epoxy_wglMakeAssociatedContextCurrentAMD)(HGLRC hglrc)
return ret;
}
-PUBLIC PFNWGLMAKECURRENTPROC epoxy_wglMakeCurrent = epoxy_wglMakeCurrent_wrapped;
-PUBLIC PFNWGLMAKECONTEXTCURRENTEXTPROC epoxy_wglMakeContextCurrentEXT = epoxy_wglMakeContextCurrentEXT_wrapped;
-PUBLIC PFNWGLMAKECONTEXTCURRENTARBPROC epoxy_wglMakeContextCurrentARB = epoxy_wglMakeContextCurrentARB_wrapped;
-PUBLIC PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC epoxy_wglMakeAssociatedContextCurrentEXT = epoxy_wglMakeAssociatedContextCurrentAMD_wrapped;
+PFNWGLMAKECURRENTPROC epoxy_wglMakeCurrent = epoxy_wglMakeCurrent_wrapped;
+PFNWGLMAKECONTEXTCURRENTEXTPROC epoxy_wglMakeContextCurrentEXT = epoxy_wglMakeContextCurrentEXT_wrapped;
+PFNWGLMAKECONTEXTCURRENTARBPROC epoxy_wglMakeContextCurrentARB = epoxy_wglMakeContextCurrentARB_wrapped;
+PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC epoxy_wglMakeAssociatedContextCurrentEXT = epoxy_wglMakeAssociatedContextCurrentAMD_wrapped;
diff --git a/src/gen_dispatch.py b/src/gen_dispatch.py
index 71c3bc1..15da2b2 100755
--- a/src/gen_dispatch.py
+++ b/src/gen_dispatch.py
@@ -77,7 +77,7 @@ class GLFunction(object):
self.public = ''
else:
self.wrapped_name = name
- self.public = 'PUBLIC '
+ self.public = 'EPOXY_PUBLIC '
# This is the string of C code for passing through the
# arguments to the function.
@@ -483,6 +483,8 @@ class Generator(object):
def write_header(self, file):
self.write_header_header(file)
+ self.outln('#include "epoxy/common.h"')
+
if self.target != "gl":
self.outln('#include "epoxy/gl.h"')
if self.target == "egl":
@@ -527,9 +529,9 @@ class Generator(object):
self.write_function_ptr_typedefs()
for func in self.sorted_functions:
- self.outln('extern EPOXY_IMPORTEXPORT {0} (EPOXY_CALLSPEC *epoxy_{1})({2});'.format(func.ret_type,
- func.name,
- func.args_decl))
+ self.outln('EPOXY_PUBLIC {0} (EPOXY_CALLSPEC *epoxy_{1})({2});'.format(func.ret_type,
+ func.name,
+ func.args_decl))
self.outln('')
for func in self.sorted_functions:
@@ -619,9 +621,7 @@ class Generator(object):
func.args_list))
def write_function_pointer(self, func):
- self.outln('{0}{1} epoxy_{2} = epoxy_{2}_global_rewrite_ptr;'.format(func.public,
- func.ptr_type,
- func.wrapped_name))
+ self.outln('{0} epoxy_{1} = epoxy_{1}_global_rewrite_ptr;'.format(func.ptr_type, func.wrapped_name))
self.outln('')
def write_provider_enums(self):
@@ -751,6 +751,8 @@ class Generator(object):
self.write_copyright_comment_body()
self.outln(' */')
self.outln('')
+ self.outln('#include "config.h"')
+ self.outln('')
self.outln('#include <stdlib.h>')
self.outln('#include <string.h>')
self.outln('#include <stdio.h>')
diff --git a/src/meson.build b/src/meson.build
index 05d4f7b..c8bb28a 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -103,7 +103,7 @@ if libtype != 'shared'
install: true,
dependencies: epoxy_deps,
include_directories: libepoxy_inc,
- c_args: common_cflags,
+ c_args: common_cflags + visibility_cflags,
link_args: common_ldflags)
libepoxy = libepoxy_static
endif