Merge branch 'symbol-visibility'

macos/v1.5.9
Emmanuele Bassi 8 years ago
commit 5bcc550a6c
  1. 52
      configure.ac
  2. 1
      include/epoxy/Makefile.am
  3. 44
      include/epoxy/common.h
  4. 16
      include/epoxy/egl.h
  5. 23
      include/epoxy/gl.h
  6. 14
      include/epoxy/glx.h
  7. 4
      include/epoxy/meson.build
  8. 16
      include/epoxy/wgl.h
  9. 17
      meson.build
  10. 10
      src/dispatch_common.c
  11. 16
      src/dispatch_common.h
  12. 4
      src/dispatch_egl.c
  13. 4
      src/dispatch_glx.c
  14. 12
      src/dispatch_wgl.c
  15. 16
      src/gen_dispatch.py
  16. 2
      src/meson.build

@ -125,25 +125,39 @@ AM_CONDITIONAL(HAS_GLES1, test x$has_gles1 = xyes)
AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])
AC_SUBST([DLOPEN_LIBS])
case $host_os in
mingw*)
# visibility flags aren't supported for windows DLLs, and the
# compiler whines to tell you so, so don't set them up.
;;
*)
if test "x$GCC" = xyes; then
save_CFLAGS="$CFLAGS"
AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
VISIBILITY_CFLAGS="-fvisibility=hidden"
CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
[VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);
# Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
CFLAGS=$save_CFLAGS
fi
;;
esac
VISIBILITY_CFLAGS=""
AS_CASE(["$host"],
[*-*-mingw*], [
dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
AC_DEFINE([EPOXY_PUBLIC],
[__attribute__((visibility("default"))) __declspec(dllexport) extern],
[defines how to decorate public symbols while building])
VISIBILITY_CFLAGS="-fvisibility=hidden"
],
[
dnl on other compilers, check if we can do -fvisibility=hidden
SAVED_CFLAGS="${CFLAGS}"
CFLAGS="-fvisibility=hidden"
AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
AC_TRY_COMPILE([], [int main (void) { return 0; }], [
AC_MSG_RESULT(yes)
enable_fvisibility_hidden=yes
], [
AC_MSG_RESULT(no)
enable_fvisibility_hidden=no
])
CFLAGS="${SAVED_CFLAGS}"
AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
AC_DEFINE([EPOXY_PUBLIC],
[__attribute__((visibility("default"))) extern],
[defines how to decorate public symbols while building])
VISIBILITY_CFLAGS="-fvisibility=hidden"
])
]
)
AC_SUBST([VISIBILITY_CFLAGS])

@ -22,6 +22,7 @@
epoxyincludedir = $(includedir)/epoxy
epoxyinclude_HEADERS = \
common.h \
gl.h \
$(EGL_INCLUDES) \
$(GLX_INCLUDES) \

@ -0,0 +1,44 @@
/*
* Copyright 2017 Emmanuele Bassi
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
/** @file common.h
*
* A common header file, used to define macros and shared symbols.
*/
#ifndef EPOXY_COMMON_H
#define EPOXY_COMMON_H
#ifdef __cplusplus
# define EPOXY_BEGIN_DECLS extern "C" {
# define EPOXY_END_DECLS }
#else
# define EPOXY_BEGIN_DECLS
# define EPOXY_END_DECLS
#endif
#ifndef EPOXY_PUBLIC
# define EPOXY_PUBLIC extern
#endif
#endif /* EPOXY_COMMON_H */

@ -30,12 +30,10 @@
#ifndef EPOXY_EGL_H
#define EPOXY_EGL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include "epoxy/common.h"
#if defined(__egl_h_) || defined(__eglext_h_)
#error epoxy/egl.h must be included before (or in place of) GL/egl.h
#else
@ -45,11 +43,11 @@ extern "C" {
#include "epoxy/egl_generated.h"
bool epoxy_has_egl_extension(EGLDisplay dpy, const char *extension);
int epoxy_egl_version(EGLDisplay dpy);
EPOXY_BEGIN_DECLS
#ifdef __cplusplus
} /* extern "C" */
#endif
EPOXY_PUBLIC bool epoxy_has_egl_extension(EGLDisplay dpy, const char *extension);
EPOXY_PUBLIC int epoxy_egl_version(EGLDisplay dpy);
EPOXY_END_DECLS
#endif /* EPOXY_EGL_H */

@ -30,12 +30,10 @@
#ifndef EPOXY_GL_H
#define EPOXY_GL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include "epoxy/common.h"
#if defined(__gl_h_) || defined(__glext_h_)
#error epoxy/gl.h must be included before (or in place of) GL/gl.h
#else
@ -51,7 +49,6 @@ extern "C" {
/* APIENTRY and GLAPIENTRY are not used on Linux or Mac. */
#define APIENTRY
#define GLAPIENTRY
#define EPOXY_IMPORTEXPORT
#define EPOXY_CALLSPEC
#define GLAPI
#define KHRONOS_APIENTRY
@ -70,10 +67,6 @@ extern "C" {
#define EPOXY_CALLSPEC __stdcall
#endif
#ifndef EPOXY_IMPORTEXPORT
#define EPOXY_IMPORTEXPORT __declspec(dllimport)
#endif
#ifndef GLAPI
#define GLAPI extern
#endif
@ -93,12 +86,12 @@ extern "C" {
#include "epoxy/gl_generated.h"
EPOXY_IMPORTEXPORT bool epoxy_has_gl_extension(const char *extension);
EPOXY_IMPORTEXPORT bool epoxy_is_desktop_gl(void);
EPOXY_IMPORTEXPORT int epoxy_gl_version(void);
EPOXY_BEGIN_DECLS
#ifdef __cplusplus
} /* extern "C" */
#endif
EPOXY_PUBLIC bool epoxy_has_gl_extension(const char *extension);
EPOXY_PUBLIC bool epoxy_is_desktop_gl(void);
EPOXY_PUBLIC int epoxy_gl_version(void);
EPOXY_END_DECLS
#endif /* EPOXY_GL_H */

@ -30,10 +30,6 @@
#ifndef EPOXY_GLX_H
#define EPOXY_GLX_H
#ifdef __cplusplus
extern "C" {
#endif
#include <epoxy/gl.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@ -49,11 +45,11 @@ extern "C" {
#include "epoxy/glx_generated.h"
bool epoxy_has_glx_extension(Display *dpy, int screen, const char *extension);
int epoxy_glx_version(Display *dpy, int screen);
EPOXY_BEGIN_DECLS
#ifdef __cplusplus
} /* extern "C" */
#endif
EPOXY_PUBLIC bool epoxy_has_glx_extension(Display *dpy, int screen, const char *extension);
EPOXY_PUBLIC int epoxy_glx_version(Display *dpy, int screen);
EPOXY_END_DECLS
#endif /* EPOXY_GLX_H */

@ -1,3 +1,5 @@
headers = [ 'common.h' ]
gl_generated = custom_target('gl_generated.h',
input: gl_registry,
output: [
@ -15,7 +17,7 @@ gl_generated = custom_target('gl_generated.h',
install_dir: join_paths(epoxy_includedir, 'epoxy'))
gen_headers = [ gl_generated ]
headers = [ 'gl.h', ]
headers += [ 'gl.h', ]
if build_egl
egl_generated = custom_target('egl_generated.h',

@ -30,13 +30,11 @@
#ifndef EPOXY_WGL_H
#define EPOXY_WGL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <windows.h>
#include "epoxy/common.h"
#undef wglUseFontBitmaps
#undef wglUseFontOutlines
@ -54,11 +52,11 @@ extern "C" {
#include "epoxy/wgl_generated.h"
EPOXY_IMPORTEXPORT bool epoxy_has_wgl_extension(HDC hdc, const char *extension);
EPOXY_IMPORTEXPORT void epoxy_handle_external_wglMakeCurrent(void);
EPOXY_BEGIN_DECLS
#ifdef __cplusplus
} /* extern "C" */
#endif
EPOXY_PUBLIC bool epoxy_has_wgl_extension(HDC hdc, const char *extension);
EPOXY_PUBLIC void epoxy_handle_external_wglMakeCurrent(void);
EPOXY_END_DECLS
#endif /* EPOXY_WGL_H */

@ -91,6 +91,23 @@ foreach cflag: test_cflags
endif
endforeach
# Visibility compiler flags
visibility_cflags = []
if get_option('default_library') != 'static'
if host_system == 'windows'
conf.set('DLL_EXPORT', true)
if cc.get_id() == 'msvc'
conf.set('EPOXY_PUBLIC', '__declspec(dllexport) extern')
else
conf.set('EPOXY_PUBLIC', '__attribute__((visibility("default"))) __declspec(dllexport) extern')
visibility_cflags += [ '-fvisibility=hidden' ]
endif
else
conf.set('EPOXY_PUBLIC', '__attribute__((visibility("default")))')
visibility_cflags += [ '-fvisibility=hidden' ]
endif
endif
# Dependencies
dl_dep = cc.find_library('dl', required: false)
gl_dep = dependency('gl', required: false)

@ -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;

@ -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

@ -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);

@ -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

@ -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;

@ -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.
@ -485,6 +485,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":
@ -529,9 +531,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:
@ -621,9 +623,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):
@ -753,6 +753,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>')

@ -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

Loading…
Cancel
Save