From 44d51f28445d40451bc600b26f3b4b17fd003c67 Mon Sep 17 00:00:00 2001 From: Yaron Cohen-Tal Date: Thu, 3 Sep 2015 23:17:39 +0300 Subject: [PATCH] Fix support for a static build of Epoxy. Add support building and running tests with CMake. Add support for linking with the static run-time library with MSVC. --- CMakeLists.txt | 88 +++++++++++---- README.md | 16 ++- cmake/FindEGL.cmake | 12 ++ cmake/FindGLESv1.cmake | 12 ++ cmake/FindGLESv2.cmake | 12 ++ cmake/epoxy_run_test_wrapper.cmake | 17 +++ include/epoxy/common.h | 29 +++-- src/CMakeLists.txt | 85 +++++++------- src/dispatch_common.c | 3 +- src/dispatch_common.h | 0 src/dispatch_egl.c | 2 +- src/dispatch_wgl.c | 75 +++++++++++++ src/dllmain.c | 101 ----------------- test/CMakeLists.txt | 150 +++++++++++++++++++++++++ test/egl_and_glx_different_pointers.c | 5 +- test/egl_gl.c | 3 +- test/egl_has_extension_nocontext.c | 3 +- test/egl_without_glx.c | 3 +- test/glx_alias_prefer_same_name.c | 5 +- test/glx_beginend.c | 3 +- test/glx_common.c | 4 +- test/glx_gles2.c | 4 +- test/glx_glxgetprocaddress_nocontext.c | 3 +- test/glx_has_extension_nocontext.c | 3 +- test/glx_public_api.c | 3 +- test/glx_public_api_core.c | 3 +- test/glx_static.c | 3 +- test/headerguards.c | 43 +++---- test/khronos_typedefs_nonepoxy.c | 21 +--- test/miscdefines.c | 6 +- test/wgl_common.c | 4 +- test/wgl_core_and_exts.c | 4 +- test/wgl_per_context_funcptrs.c | 6 +- test/wgl_usefontbitmaps.c | 8 +- 34 files changed, 472 insertions(+), 267 deletions(-) create mode 100644 cmake/FindEGL.cmake create mode 100644 cmake/FindGLESv1.cmake create mode 100644 cmake/FindGLESv2.cmake create mode 100644 cmake/epoxy_run_test_wrapper.cmake mode change 100755 => 100644 src/dispatch_common.h delete mode 100644 src/dllmain.c create mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f2b43a..61fef4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,50 +1,98 @@ cmake_minimum_required (VERSION 3.0) -cmake_policy (VERSION 3.0) if (NOT CMAKE_VERSION VERSION_LESS "3.1") - cmake_policy (SET CMP0054 NEW) + cmake_policy (SET CMP0054 OLD) +endif () +if (NOT CMAKE_VERSION VERSION_LESS "3.3") + cmake_policy (SET CMP0063 NEW) + set (HONOR_VISIBILITY TRUE) +else () + set (HONOR_VISIBILITY FALSE) endif () project (Epoxy VERSION 1.3.1 LANGUAGES C) -set (TARGET_NAME epoxy) -set (TARGET_VER 1.3.1_yaronct-4) +set (EPOXY_TARGET_NAME epoxy) +set (TARGET_VER 1.3.1_yaronct-5) set (TARGET_ABI_VER 0) -set (TARGET_OUTPUT_NAME "${TARGET_NAME}") +set (TARGET_OUTPUT_NAME "${EPOXY_TARGET_NAME}") + +include (GNUInstallDirs) +include (CMakeDependentOption) -set (CMAKE_C_VISIBILITY_PRESET "hidden") +set (COMPILER_ID_MSVC MSVC) +set (COMPILER_ID_GCC GNU) +set (COMPILER_ID_CLANG Clang) -if ((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR (CMAKE_C_COMPILER_ID STREQUAL "Clang")) +if ((CMAKE_C_COMPILER_ID STREQUAL COMPILER_ID_GCC) OR (CMAKE_C_COMPILER_ID STREQUAL COMPILER_ID_CLANG)) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") elseif (NOT CMAKE_VERSION VERSION_LESS "3.1") set (CMAKE_C_STANDARD_REQUIRED TRUE) set (CMAKE_C_STANDARD "99") endif () -if ((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR (CMAKE_C_COMPILER_ID STREQUAL "Clang")) +if ((CMAKE_C_COMPILER_ID STREQUAL COMPILER_ID_GCC) OR (CMAKE_C_COMPILER_ID STREQUAL COMPILER_ID_CLANG)) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -Wall -Wextra") -elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC") - if (NOT CMAKE_C_FLAGS MATCHES "/W[0-4]") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") - endif () +elseif (CMAKE_C_COMPILER_ID STREQUAL COMPILER_ID_MSVC) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") endif () set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") find_package (X11) find_package (PythonInterp) +find_package (EGL) +find_package (GLESv1) +find_package (GLESv2) +find_package (OpenGL) -include (CMakeDependentOption) - -option (EPOXY_REBUILD_FROM_SPECS "Whether to rebuild the auto-generated sources and headers from the specs" FALSE) +option (EPOXY_REBUILD_FROM_SPECS "Rebuild the auto-generated sources and headers from the specs" FALSE) if (EPOXY_REBUILD_FROM_SPECS AND NOT PYTHONINTERP_FOUND) message (FATAL_ERROR "You've set \"EPOXY_REBUILD_FROM_SPECS\" to \"TRUE\", which requires a python interpreter, but one couldn't be found.") endif () -option (EPOXY_SUPPORT_EGL "Whether to build with EGL support" TRUE) -cmake_dependent_option (EPOXY_SUPPORT_WGL "Whether to build with WGL support" ON WIN32 OFF) -cmake_dependent_option (EPOXY_SUPPORT_GLX "Whether to build with GLX support" "${X11_FOUND}" "NOT (WIN32 OR ANDROID)" OFF) +option (EPOXY_SUPPORT_EGL "Build with EGL support" ON) +cmake_dependent_option (EPOXY_SUPPORT_WGL "Build with WGL support" ON WIN32 OFF) + +if (X11_FOUND AND OPENGL_FOUND) + set (EPOXY_GLX_FOUND TRUE) +else () + set (EPOXY_GLX_FOUND FALSE) +endif () +cmake_dependent_option (EPOXY_SUPPORT_GLX "Build with GLX support" + "${EPOXY_GLX_FOUND}" "NOT (WIN32 OR ANDROID)" OFF) -option (EPOXY_BUILD_SHARED "Whether to build a shared library" TRUE) -option (EPOXY_BUILD_STATIC "Whether to build a static library" FALSE) +option (EPOXY_BUILD_SHARED "Build a shared library" ON) +option (EPOXY_BUILD_STATIC "Build a static library" OFF) + +if (DEFINED CMAKE_TOOLCHAIN_FILE) + set (EPOXY_BUILD_TESTS_DEFAULT FALSE) +else () + set (EPOXY_BUILD_TESTS_DEFAULT TRUE) +endif () +option (EPOXY_BUILD_TESTS "Build tests" "${EPOXY_BUILD_TESTS_DEFAULT}") + +cmake_dependent_option (EPOXY_MSVC_USE_RUNTIME_LIBRARY_DLL "Link with MSVC Runtime Library DLL" ON + "CMAKE_C_COMPILER_ID STREQUAL COMPILER_ID_MSVC" OFF) configure_file ("include/epoxy/config.h.in" "include/epoxy/config.h") +set (EPOXY_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" + "${CMAKE_CURRENT_BINARY_DIR}/include" + "${CMAKE_CURRENT_SOURCE_DIR}/src") + +if (CMAKE_C_COMPILER_ID STREQUAL COMPILER_ID_MSVC + AND NOT EPOXY_MSVC_USE_RUNTIME_LIBRARY_DLL) + foreach (flags CMAKE_C_FLAGS + CMAKE_C_FLAGS_DEBUG + CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_MINSIZEREL + CMAKE_C_FLAGS_RELWITHDEBINFO) + string (REGEX REPLACE "/MDd" "/MTd" ${flags} "${${flags}}") + string (REGEX REPLACE "/MD" "/MT" ${flags} "${${flags}}") + endforeach () +endif () + add_subdirectory (src) + +if (EPOXY_BUILD_TESTS) + enable_testing () + add_subdirectory (test) +endif () diff --git a/README.md b/README.md index 7632f3d..b7299df 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,11 @@ Features Building (CMake) ----------------- -CMake is now the recommended way to build epoxy. It should be as simple as: +CMake is now the recommended way to build epoxy. It supports building both +shared and static libraries (by default only shared library is built). It also +supports building and running tests, both for the static and the shared library. + +Building with CMake should be as simple as: cd cmake @@ -46,8 +50,11 @@ solution. * To disable building shared libraries, add "-DEPOXY_BUILD_SHARED=OFF" to the "cmake" invocation. -Note that building with CMake currently doesn't support building or running -tests. +* To disable building tests, add +"-DEPOXY_BUILD_TESTS=OFF" to the "cmake" invocation. + +* To link to the static Runtime Library with MSVC (rather than to the DLL), add +"-DEPOXY_MSVC_USE_RUNTIME_LIBRARY_DLL=OFF" to the "cmake" invocation. Building (Autotools) --------------------- @@ -100,6 +107,9 @@ tests. Switching your Code to Use Epoxy --------------------------------- +* NOTE: If you use the static version of Epoxy, you must build your project with + "EPOXY_STATIC_LIB" defined! + It should be as easy as replacing: #include diff --git a/cmake/FindEGL.cmake b/cmake/FindEGL.cmake new file mode 100644 index 0000000..0dba882 --- /dev/null +++ b/cmake/FindEGL.cmake @@ -0,0 +1,12 @@ +# Find EGL +# +# EGL_LIBRARY +# EGL_FOUND + +set (EGL_NAMES ${EGL_NAMES} egl EGL libEGL) +find_library (EGL_LIBRARY NAMES ${EGL_NAMES} PATHS /opt/vc/lib) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(EGL DEFAULT_MSG EGL_LIBRARY) + +mark_as_advanced(EGL_LIBRARY) diff --git a/cmake/FindGLESv1.cmake b/cmake/FindGLESv1.cmake new file mode 100644 index 0000000..4bc5b7b --- /dev/null +++ b/cmake/FindGLESv1.cmake @@ -0,0 +1,12 @@ +# Find GLESv1 +# +# GLESv1_LIBRARY +# GLESv1_FOUND + +set(GLESv1_NAMES ${GLESv1_NAMES} GLESv1_CM libGLES_CM) +find_library (GLESv1_LIBRARY NAMES ${GLESv1_NAMES} PATHS /opt/vc/lib) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args (GLESv1 DEFAULT_MSG GLESv1_LIBRARY) + +mark_as_advanced (GLESv1_LIBRARY) diff --git a/cmake/FindGLESv2.cmake b/cmake/FindGLESv2.cmake new file mode 100644 index 0000000..f2f7671 --- /dev/null +++ b/cmake/FindGLESv2.cmake @@ -0,0 +1,12 @@ +# Find GLESv2 +# +# GLESv2_LIBRARY +# GLESv2_FOUND + +set (GLESv2_NAMES ${GLESv2_NAMES} GLESv2 libGLESv2) +find_library (GLESv2_LIBRARY NAMES ${GLESv2_NAMES} PATHS /opt/vc/lib) + +include (FindPackageHandleStandardArgs) +find_package_handle_standard_args (GLESv2 DEFAULT_MSG GLESv2_LIBRARY) + +mark_as_advanced (GLESv2_LIBRARY) diff --git a/cmake/epoxy_run_test_wrapper.cmake b/cmake/epoxy_run_test_wrapper.cmake new file mode 100644 index 0000000..d2a8f99 --- /dev/null +++ b/cmake/epoxy_run_test_wrapper.cmake @@ -0,0 +1,17 @@ +cmake_minimum_required (VERSION 3.0) +if (NOT CMAKE_VERSION VERSION_LESS "3.1") + cmake_policy (SET CMP0054 OLD) +endif () +if (WIN32 AND DEFINED EPOXY_SHARED_LIB) + get_filename_component (EPOXY_SHARED_LIB_DIR "${EPOXY_SHARED_LIB}" DIRECTORY) + file (TO_NATIVE_PATH "${EPOXY_SHARED_LIB_DIR}" EPOXY_SHARED_LIB_DIR) + if (NOT DEFINED ENV{PATH} OR ENV{PATH} STREQUAL "") + set (ENV{PATH} "${EPOXY_SHARED_LIB_DIR}") + else () + set (ENV{PATH} "${EPOXY_SHARED_LIB_DIR};$ENV{PATH}") + endif () +endif () +execute_process (COMMAND "${EPOXY_TEST_CMD}" RESULT_VARIABLE TEST_RETURN_VAL) +if (NOT TEST_RETURN_VAL EQUAL 0 AND NOT TEST_RETURN_VAL EQUAL 77) + message (FATAL_ERROR "Test has failed!") +endif () diff --git a/include/epoxy/common.h b/include/epoxy/common.h index a190e02..cf1badf 100644 --- a/include/epoxy/common.h +++ b/include/epoxy/common.h @@ -38,28 +38,35 @@ extern "C" { #endif #if defined _WIN32 || defined __CYGWIN__ - #ifdef EPOXY_EXPORTS - #ifdef __GNUC__ - #define EPOXY_IMPORTEXPORT __attribute__ ((dllexport)) - #else - #define EPOXY_IMPORTEXPORT __declspec(dllexport) - #endif + #if defined EPOXY_STATIC_LIB + #define EPOXY_IMPORTEXPORT #else - #ifdef __GNUC__ - #define EPOXY_IMPORTEXPORT __attribute__ ((dllimport)) + #if defined EPOXY_BUILDING_LIB + #ifdef __GNUC__ + #define EPOXY_IMPORTEXPORT __attribute__((dllexport)) + #else + #define EPOXY_IMPORTEXPORT __declspec(dllexport) + #endif #else - #define EPOXY_IMPORTEXPORT __declspec(dllimport) + #ifdef __GNUC__ + #define EPOXY_IMPORTEXPORT __attribute__((dllimport)) + #else + #define EPOXY_IMPORTEXPORT __declspec(dllimport) + #endif #endif #endif #elif defined __ANDROID__ #include #define EPOXY_IMPORTEXPORT __attribute__((visibility("default"))) __NDK_FPABI__ -#elif (defined __GNUC__ && __GNUC__ >= 4) || (defined __SUNPRO_C && __SUNPRO_C >= 0x590) - #define EPOXY_IMPORTEXPORT __attribute__ ((visibility ("default"))) +#elif (defined __GNUC__ && __GNUC__ >= 4) || (defined __SUNPRO_C && __SUNPRO_C >= 0x590) + #define EPOXY_IMPORTEXPORT __attribute__((visibility("default"))) #else #define EPOXY_IMPORTEXPORT #endif +// Prevent "unused variable/parameter" warnings. +#define EPOXY_UNUSED(var) ((void)var) + #ifdef __cplusplus } #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 631f102..9fdf7a8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,62 +63,61 @@ if (EPOXY_SUPPORT_WGL) "${CMAKE_CURRENT_BINARY_DIR}/../include/epoxy/wgl_generated.h") endif () -set (EPOXY_INCLUDE_DIRS "../include" - "${CMAKE_CURRENT_BINARY_DIR}/../include" - "${CMAKE_CURRENT_SOURCE_DIR}") - -set (TARGET_OBJS_NAME "${TARGET_NAME}_objs") -add_library ("${TARGET_NAME}_objs" OBJECT ${SOURCES} ${HEADERS}) -set_target_properties ("${TARGET_NAME}_objs" PROPERTIES - POSITION_INDEPENDENT_CODE TRUE) -target_include_directories ("${TARGET_NAME}_objs" PUBLIC ${EPOXY_INCLUDE_DIRS}) -if (CMAKE_C_COMPILER_ID STREQUAL "MSVC") - target_compile_definitions ("${TARGET_NAME}_objs" PUBLIC "inline=__inline" EPOXY_EXPORTS) -endif () -set (EPOXY_LIBS_FILES $) -if (WIN32) - set (EPOXY_LIBS_EXTRA_FILES dllmain.c) -else () - set (EPOXY_LIBS_EXTRA_FILES "") +set (EPOXY_COMPILE_DEFS PRIVATE EPOXY_BUILDING_LIB) +if (CMAKE_C_COMPILER_ID STREQUAL COMPILER_ID_MSVC) + set (EPOXY_COMPILE_DEFS ${EPOXY_COMPILE_DEFS} "inline=__inline") endif () -set (TARGETS_BUILT_NAMES "") +set (EPOXY_TARGET_CODE ${SOURCES} ${HEADERS}) + +set (EPOXY_TARGETS_BUILT_NAMES "") + if (EPOXY_BUILD_SHARED) - list (APPEND TARGETS_BUILT_NAMES "${TARGET_NAME}_shared") - add_library ("${TARGET_NAME}_shared" SHARED $ ${EPOXY_LIBS_EXTRA_FILES}) + list (APPEND EPOXY_TARGETS_BUILT_NAMES "${EPOXY_TARGET_NAME}_shared") + add_library ("${EPOXY_TARGET_NAME}_shared" SHARED ${EPOXY_TARGET_CODE}) + target_link_libraries ("${EPOXY_TARGET_NAME}_shared" ${CMAKE_DL_LIBS}) if (WIN32 OR ANDROID) - set_target_properties ("${TARGET_NAME}_shared" PROPERTIES - OUTPUT_NAME "${TARGET_OUTPUT_NAME}_${TARGET_ABI_VER}") + set_target_properties ("${EPOXY_TARGET_NAME}_shared" PROPERTIES + OUTPUT_NAME "${TARGET_OUTPUT_NAME}_${TARGET_ABI_VER}") else () - set_target_properties ("${TARGET_NAME}_shared" PROPERTIES - OUTPUT_NAME "${TARGET_OUTPUT_NAME}") + set_target_properties ("${EPOXY_TARGET_NAME}_shared" PROPERTIES + OUTPUT_NAME "${TARGET_OUTPUT_NAME}") endif () if (NOT ANDROID) - set_target_properties("${TARGET_NAME}_shared" PROPERTIES - VERSION "${TARGET_VER}" - SOVERSION "${TARGET_ABI_VER}") + set_target_properties("${EPOXY_TARGET_NAME}_shared" PROPERTIES + VERSION "${TARGET_VER}" + SOVERSION "${TARGET_ABI_VER}") endif () - target_include_directories ("${TARGET_NAME}_shared" PUBLIC ${EPOXY_INCLUDE_DIRS}) - target_compile_definitions ("${TARGET_NAME}_shared" PUBLIC EPOXY_EXPORTS EPOXY_BUILDING_SHARED_LIB) + target_include_directories ("${EPOXY_TARGET_NAME}_shared" PUBLIC ${EPOXY_INCLUDE_DIRS}) + target_compile_definitions ("${EPOXY_TARGET_NAME}_shared" PRIVATE ${EPOXY_COMPILE_DEFS}) + set_target_properties ("${EPOXY_TARGET_NAME}_shared" PROPERTIES C_VISIBILITY_PRESET hidden) endif () + if (EPOXY_BUILD_STATIC) - list (APPEND TARGETS_BUILT_NAMES "${TARGET_NAME}_static") - add_library ("${TARGET_NAME}_static" STATIC $ ${EPOXY_LIBS_EXTRA_FILES}) + list (APPEND EPOXY_TARGETS_BUILT_NAMES "${EPOXY_TARGET_NAME}_static") + add_library ("${EPOXY_TARGET_NAME}_static" STATIC ${EPOXY_TARGET_CODE}) + target_link_libraries ("${EPOXY_TARGET_NAME}_static" ${CMAKE_DL_LIBS}) if (WIN32) - set_target_properties ("${TARGET_NAME}_static" PROPERTIES - OUTPUT_NAME "${TARGET_OUTPUT_NAME}_static_${TARGET_ABI_VER}") + set_target_properties ("${EPOXY_TARGET_NAME}_static" PROPERTIES + OUTPUT_NAME "${TARGET_OUTPUT_NAME}_static_${TARGET_ABI_VER}") else () - set_target_properties ("${TARGET_NAME}_static" PROPERTIES - OUTPUT_NAME "${TARGET_OUTPUT_NAME}_${TARGET_ABI_VER}") + set_target_properties ("${EPOXY_TARGET_NAME}_static" PROPERTIES + OUTPUT_NAME "${TARGET_OUTPUT_NAME}_${TARGET_ABI_VER}") + endif () + target_include_directories ("${EPOXY_TARGET_NAME}_static" PUBLIC ${EPOXY_INCLUDE_DIRS}) + target_compile_definitions ("${EPOXY_TARGET_NAME}_static" PRIVATE ${EPOXY_COMPILE_DEFS} EPOXY_STATIC_LIB) + if (HONOR_VISIBILITY) + set_target_properties ("${EPOXY_TARGET_NAME}_static" PROPERTIES C_VISIBILITY_PRESET hidden) + elseif ((CMAKE_C_COMPILER_ID STREQUAL COMPILER_ID_GCC) OR (CMAKE_C_COMPILER_ID STREQUAL COMPILER_ID_CLANG)) + target_compile_options ("${EPOXY_TARGET_NAME}_static" PRIVATE "-fvisibility=hidden") endif () - target_include_directories ("${TARGET_NAME}_static" PUBLIC ${EPOXY_INCLUDE_DIRS}) - target_compile_definitions ("${TARGET_NAME}_static" PUBLIC EPOXY_EXPORTS EPOXY_BUILDING_STATIC_LIB) endif () + install (FILES ${HEADERS} DESTINATION "include/epoxy") -install (TARGETS ${TARGETS_BUILT_NAMES} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) -if (CMAKE_C_COMPILER_ID STREQUAL "MSVC") - INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/Debug/${TARGET_OUTPUT_NAME}_${TARGET_ABI_VER}.pdb" +install (TARGETS ${EPOXY_TARGETS_BUILT_NAMES} + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") +if (CMAKE_C_COMPILER_ID STREQUAL COMPILER_ID_MSVC) + install (FILES "${CMAKE_CURRENT_BINARY_DIR}/Debug/${TARGET_OUTPUT_NAME}_${TARGET_ABI_VER}.pdb" DESTINATION lib CONFIGURATIONS Debug) endif () diff --git a/src/dispatch_common.c b/src/dispatch_common.c index 0d4f68f..1667119 100644 --- a/src/dispatch_common.c +++ b/src/dispatch_common.c @@ -224,6 +224,7 @@ get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail) } #ifdef _WIN32 + EPOXY_UNUSED(exit_on_fail); *handle = LoadLibraryA(lib_name); #else pthread_mutex_lock(&api.mutex); @@ -361,7 +362,7 @@ bool epoxy_extension_in_string(const char *extension_list, const char *ext) { const char *ptr = extension_list; - int len = strlen(ext); + size_t len = strlen(ext); /* Make sure that don't just find an extension with our name as a prefix. */ while (true) { diff --git a/src/dispatch_common.h b/src/dispatch_common.h old mode 100755 new mode 100644 diff --git a/src/dispatch_egl.c b/src/dispatch_egl.c index 5bb1633..b6613d3 100644 --- a/src/dispatch_egl.c +++ b/src/dispatch_egl.c @@ -52,7 +52,7 @@ epoxy_egl_version(EGLDisplay dpy) version_string = eglQueryString(dpy, EGL_VERSION); ret = sscanf(version_string, "%d.%d", &major, &minor); - (void)ret; // Prevent "warning: variable 'ret' set but not used". + EPOXY_UNUSED(ret); assert(ret == 2); return major * 10 + minor; } diff --git a/src/dispatch_wgl.c b/src/dispatch_wgl.c index 3ce4406..bbb5528 100644 --- a/src/dispatch_wgl.c +++ b/src/dispatch_wgl.c @@ -89,6 +89,81 @@ epoxy_handle_external_wglMakeCurrent(void) } } +/** + * This global symbol is apparently looked up by Windows when loading + * a DLL, but it doesn't declare the prototype. + */ +BOOL WINAPI +DllMain(HINSTANCE dll, DWORD reason, LPVOID reserved); + +BOOL WINAPI +DllMain(HINSTANCE dll, DWORD reason, LPVOID reserved) +{ + void *data; + + (void)dll; // Prevent "unused parameter" warning. + (void)reserved; // Prevent "unused parameter" warning. + switch (reason) { + case DLL_PROCESS_ATTACH: + gl_tls_index = TlsAlloc(); + if (gl_tls_index == TLS_OUT_OF_INDEXES) + return FALSE; + wgl_tls_index = TlsAlloc(); + if (wgl_tls_index == TLS_OUT_OF_INDEXES) + return FALSE; + + epoxy_first_context_current = false; + + /* FALLTHROUGH */ + + case DLL_THREAD_ATTACH: + data = LocalAlloc(LPTR, gl_tls_size); + TlsSetValue(gl_tls_index, data); + + data = LocalAlloc(LPTR, wgl_tls_size); + TlsSetValue(wgl_tls_index, data); + + break; + + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + data = TlsGetValue(gl_tls_index); + LocalFree(data); + + data = TlsGetValue(wgl_tls_index); + LocalFree(data); + + if (reason == DLL_PROCESS_DETACH) { + TlsFree(gl_tls_index); + TlsFree(wgl_tls_index); + } + break; + } + + return TRUE; +} + +#ifdef EPOXY_STATIC_LIB +#ifdef __GNUC__ + PIMAGE_TLS_CALLBACK dllmain_callback __attribute__((section(".CRT$XLB"))) = (PIMAGE_TLS_CALLBACK)DllMain; +#else +# ifdef _WIN64 +# pragma comment(linker, "/INCLUDE:_tls_used") +# pragma comment(linker, "/INCLUDE:dllmain_callback") +# pragma const_seg(".CRT$XLB") + extern const PIMAGE_TLS_CALLBACK dllmain_callback; + const PIMAGE_TLS_CALLBACK dllmain_callback = DllMain; +# pragma const_seg() +# else +# pragma comment(linker, "/INCLUDE:__tls_used") +# pragma comment(linker, "/INCLUDE:_dllmain_callback") +# pragma data_seg(".CRT$XLB") + PIMAGE_TLS_CALLBACK dllmain_callback = DllMain; +# pragma data_seg() +# endif +#endif +#endif + WRAPPER_VISIBILITY (BOOL) WRAPPER(epoxy_wglMakeCurrent)(HDC hdc, HGLRC hglrc) { diff --git a/src/dllmain.c b/src/dllmain.c deleted file mode 100644 index 861665f..0000000 --- a/src/dllmain.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright © 2013 Intel Corporation - * - * 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. - */ - -#if !defined _WIN32 -#error This file should only be used in Windows. -#endif - -#include "dispatch_common.h" - -/** - * This global symbol is apparently looked up by Windows when loading - * a DLL, but it doesn't declare the prototype. - */ -BOOL WINAPI -DllMain(HINSTANCE dll, DWORD reason, LPVOID reserved); - -BOOL WINAPI -DllMain(HINSTANCE dll, DWORD reason, LPVOID reserved) -{ - void *data; - - switch (reason) { - case DLL_PROCESS_ATTACH: - gl_tls_index = TlsAlloc(); - if (gl_tls_index == TLS_OUT_OF_INDEXES) - return FALSE; - wgl_tls_index = TlsAlloc(); - if (wgl_tls_index == TLS_OUT_OF_INDEXES) - return FALSE; - - epoxy_first_context_current = false; - - /* FALLTHROUGH */ - - case DLL_THREAD_ATTACH: - data = LocalAlloc(LPTR, gl_tls_size); - TlsSetValue(gl_tls_index, data); - - data = LocalAlloc(LPTR, wgl_tls_size); - TlsSetValue(wgl_tls_index, data); - - break; - - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - data = TlsGetValue(gl_tls_index); - LocalFree(data); - - data = TlsGetValue(wgl_tls_index); - LocalFree(data); - - if (reason == DLL_PROCESS_DETACH) { - TlsFree(gl_tls_index); - TlsFree(wgl_tls_index); - } - break; - } - - return TRUE; -} - -#ifdef EPOXY_BUILDING_STATIC_LIB -#ifdef __GNUC__ - PIMAGE_TLS_CALLBACK dllmain_callback __attribute__((section(".CRT$XLB"))) = (PIMAGE_TLS_CALLBACK)DllMain; -#else -# ifdef _WIN64 -# pragma comment(linker, "/INCLUDE:_tls_used") -# pragma comment(linker, "/INCLUDE:dllmain_callback") -# pragma const_seg(".CRT$XLB") - extern const PIMAGE_TLS_CALLBACK dllmain_callback; - const PIMAGE_TLS_CALLBACK dllmain_callback = DllMain; -# pragma const_seg() -# else -# pragma comment(linker, "/INCLUDE:__tls_used") -# pragma comment(linker, "/INCLUDE:_dllmain_callback") -# pragma data_seg(".CRT$XLB") - PIMAGE_TLS_CALLBACK dllmain_callback = DllMain; -# pragma data_seg() -# endif -#endif -#endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..ef3511b --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,150 @@ +if (EPOXY_BUILD_TESTS) + + if (EPOXY_BUILD_SHARED) + set (TESTS_TARGET_NAME "${EPOXY_TARGET_NAME}_shared") + else () + set (TESTS_TARGET_NAME "${EPOXY_TARGET_NAME}_static") + endif () + + if (EPOXY_SUPPORT_EGL) + if (EGL_FOUND) + set (EPOXY_BUILD_EGL_TESTS TRUE) + set (EPOXY_EGL_TESTS_COMMON egl_common.c egl_common.h) + else () + set (EPOXY_BUILD_EGL_TESTS FALSE) + message (WARNING "EGL not found - EGL tests will not be built!") + endif () + endif () + if (EPOXY_SUPPORT_GLX) + set (EPOXY_GLX_TESTS_COMMON glx_common.c glx_common.h) + endif () + if (EPOXY_SUPPORT_WGL) + set (EPOXY_WGL_TESTS_COMMON wgl_common.c wgl_common.h) + endif () + + set (EPOXY_LINKAGE_TYPE_SHARED SHARED) + set (EPOXY_LINKAGE_TYPE_STATIC STATIC) + + function (epoxy_add_test EPOXY_TEST_NAME EPOXY_TEST_CODE) + # Additional optional arguments: "EPOXY_TEST_DEPS EPOXY_TEST_COMPILE_DEFS EPOXY_TEST_LINK_FLAGS" + # "EPOXY_LINKAGE_TYPE" + + if (ARGC GREATER 2) + set (EPOXY_TEST_DEPS "${ARGV2}") + else () + set (EPOXY_TEST_DEPS "") + endif () + if (ARGC GREATER 3) + set (EPOXY_TEST_COMPILE_DEFS "${ARGV3}") + else () + set (EPOXY_TEST_COMPILE_DEFS "") + endif () + if (ARGC GREATER 4) + set (EPOXY_TEST_LINK_FLAGS "${ARGV4}") + else () + set (EPOXY_TEST_LINK_FLAGS "") + endif () + if (ARGC GREATER 5) + set (EPOXY_TEST_LINKAGE_TYPE "${ARGV5}") + else () + set (EPOXY_TEST_LINKAGE_TYPE BOTH) + endif () + + if (EPOXY_BUILD_SHARED AND NOT EPOXY_TEST_LINKAGE_TYPE STREQUAL EPOXY_LINKAGE_TYPE_STATIC) + set (EPOXY_TEST_TARGET_NAME "test_shared_${EPOXY_TEST_NAME}") + add_executable (${EPOXY_TEST_TARGET_NAME} ${EPOXY_TEST_CODE}) + target_link_libraries (${EPOXY_TEST_TARGET_NAME} "${EPOXY_TARGET_NAME}_shared" ${EPOXY_TEST_DEPS}) + target_compile_definitions (${EPOXY_TEST_TARGET_NAME} PRIVATE + ${EPOXY_TEST_COMPILE_DEFS}) + target_include_directories (${EPOXY_TEST_TARGET_NAME} PRIVATE ${EPOXY_INCLUDE_DIRS}) + set_target_properties (${EPOXY_TEST_TARGET_NAME} PROPERTIES + LINK_FLAGS "${EPOXY_TEST_LINK_FLAGS}") + add_test (NAME "${EPOXY_TEST_TARGET_NAME}" + COMMAND "${CMAKE_COMMAND}" + "-DEPOXY_TEST_CMD=$" + "-DEPOXY_SHARED_LIB=$" + "-P" "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/epoxy_run_test_wrapper.cmake") + endif () + + if (EPOXY_BUILD_STATIC AND NOT EPOXY_TEST_LINKAGE_TYPE STREQUAL EPOXY_LINKAGE_TYPE_SHARED) + set (EPOXY_TEST_TARGET_NAME "test_static_${EPOXY_TEST_NAME}") + add_executable (${EPOXY_TEST_TARGET_NAME} ${EPOXY_TEST_CODE}) + target_link_libraries (${EPOXY_TEST_TARGET_NAME} "${EPOXY_TARGET_NAME}_static" ${EPOXY_TEST_DEPS}) + target_compile_definitions (${EPOXY_TEST_TARGET_NAME} PRIVATE + ${EPOXY_TEST_COMPILE_DEFS} EPOXY_STATIC_LIB) + target_include_directories (${EPOXY_TEST_TARGET_NAME} PRIVATE ${EPOXY_INCLUDE_DIRS}) + set_target_properties (${EPOXY_TEST_TARGET_NAME} PROPERTIES + LINK_FLAGS "${EPOXY_TEST_LINK_FLAGS}") + add_test (NAME "${EPOXY_TEST_TARGET_NAME}" + COMMAND "${CMAKE_COMMAND}" + "-DEPOXY_TEST_CMD=$" + "-P" "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/epoxy_run_test_wrapper.cmake") + endif () + + endfunction () + + if (EPOXY_BUILD_EGL_TESTS AND X11_FOUND) + + epoxy_add_test (egl_has_extension_nocontext "${EPOXY_EGL_TESTS_COMMON};egl_has_extension_nocontext.c" + "${X11_LIBRARIES}") + epoxy_add_test (egl_gl "${EPOXY_EGL_TESTS_COMMON};egl_gl.c" "${X11_LIBRARIES}") + if (GLESv1_FOUND) + epoxy_add_test (egl_gles1_without_glx "${EPOXY_EGL_TESTS_COMMON};egl_without_glx.c" "${X11_LIBRARIES}" + "GLES_VERSION=1") + endif () + if (GLESv2_FOUND) + epoxy_add_test (egl_gles2_without_glx "${EPOXY_EGL_TESTS_COMMON};egl_without_glx.c" "${X11_LIBRARIES}" + "GLES_VERSION=2") + endif () + endif() + + if (EPOXY_BUILD_EGL_TESTS AND EPOXY_SUPPORT_GLX AND NOT APPLE) + + #epoxy_add_test (egl_and_glx_different_pointers "${EPOXY_EGL_TESTS_COMMON};${EPOXY_GLX_TESTS_COMMON};egl_and_glx_different_pointers.c;dlwrap.c;dlwrap.h" "${X11_LIBRARIES}" "USE_EGL;USE_GLX" "-rdynamic") + epoxy_add_test (egl_different_pointers + "${EPOXY_EGL_TESTS_COMMON};${EPOXY_GLX_TESTS_COMMON};egl_and_glx_different_pointers.c;dlwrap.c;dlwrap.h" + "${X11_LIBRARIES}" "USE_EGL" "-rdynamic") + epoxy_add_test (glx_different_pointers + "${EPOXY_EGL_TESTS_COMMON};${EPOXY_GLX_TESTS_COMMON};egl_and_glx_different_pointers.c;dlwrap.c;dlwrap.h" + "${X11_LIBRARIES}" "USE_GLX" "-rdynamic") + endif () + + if (EPOXY_SUPPORT_GLX) + + if (NOT APPLE) + epoxy_add_test (glx_alias_prefer_same_name + "${EPOXY_GLX_TESTS_COMMON};glx_alias_prefer_same_name.c;dlwrap.c;dlwrap.h" "${X11_LIBRARIES}" + "" "-rdynamic") + if (GLESv2_FOUND) + epoxy_add_test (test_glx_gles2 + "${EPOXY_GLX_TESTS_COMMON};glx_gles2.c;dlwrap.c;dlwrap.h" "${X11_LIBRARIES}" "" "-rdynamic") + endif () + endif () + + epoxy_add_test (test_glx_beginend "${EPOXY_GLX_TESTS_COMMON};glx_beginend.c" + "${OPENGL_gl_LIBRARY};${X11_LIBRARIES}") + epoxy_add_test (glx_public_api "${EPOXY_GLX_TESTS_COMMON};glx_public_api.c" "${X11_LIBRARIES}") + epoxy_add_test (glx_public_api_core "${EPOXY_GLX_TESTS_COMMON};glx_public_api_core.c" "${X11_LIBRARIES}") + epoxy_add_test (glx_getprocaddress_nocontext + "${EPOXY_GLX_TESTS_COMMON};glx_glxgetprocaddress_nocontext.c" "${X11_LIBRARIES}") + epoxy_add_test (glx_has_extension_nocontext "${EPOXY_GLX_TESTS_COMMON};glx_has_extension_nocontext.c" + "${X11_LIBRARIES}") + + epoxy_add_test (glx_shared_znow "${EPOXY_GLX_TESTS_COMMON};glx_static.c" + "${X11_LIBRARIES}" "" "-Wl,-z,now" SHARED) + epoxy_add_test (glx_static "${EPOXY_GLX_TESTS_COMMON};glx_static.c" + "${X11_LIBRARIES}" "NEEDS_TO_BE_STATIC" "" STATIC) + endif () + + epoxy_add_test (headerguards headerguards.c) + epoxy_add_test (miscdefines miscdefines.c) + + if (EPOXY_SUPPORT_WGL) + epoxy_add_test (wgl_core_and_exts "${EPOXY_WGL_TESTS_COMMON};wgl_core_and_exts.c") + epoxy_add_test (wgl_per_context_funcptrs "${EPOXY_WGL_TESTS_COMMON};wgl_per_context_funcptrs.c") + epoxy_add_test (wgl_usefontbitmaps_ascii "${EPOXY_WGL_TESTS_COMMON};wgl_usefontbitmaps.c") + epoxy_add_test (wgl_usefontbitmaps_unicode "${EPOXY_WGL_TESTS_COMMON};wgl_usefontbitmaps.c" + "" "_UNICODE;UNICODE") + endif () + +endif () diff --git a/test/egl_and_glx_different_pointers.c b/test/egl_and_glx_different_pointers.c index 9d95f3a..009b82b 100644 --- a/test/egl_and_glx_different_pointers.c +++ b/test/egl_and_glx_different_pointers.c @@ -83,12 +83,14 @@ override_GLES2_glGetString(GLenum e) GLuint override_GL_glCreateShader(GLenum type) { + EPOXY_UNUSED(type); return GL_CREATESHADER_VALUE; } GLuint override_GLES2_glCreateShader(GLenum type) { + EPOXY_UNUSED(type); return GLES2_CREATESHADER_VALUE; } @@ -207,8 +209,7 @@ init_egl(EGLDisplay *out_dpy, EGLContext *out_ctx) } #endif /* USE_EGL */ -int -main(int argc, char **argv) +int main(void) { bool pass = true; #ifdef USE_EGL diff --git a/test/egl_gl.c b/test/egl_gl.c index 99576d3..ec04607 100644 --- a/test/egl_gl.c +++ b/test/egl_gl.c @@ -109,8 +109,7 @@ init_egl(EGLDisplay *out_dpy, EGLContext *out_ctx) *out_ctx = ctx; } -int -main(int argc, char **argv) +int main(void) { bool pass = true; EGLDisplay egl_dpy; diff --git a/test/egl_has_extension_nocontext.c b/test/egl_has_extension_nocontext.c index e8c76a8..942c7b3 100644 --- a/test/egl_has_extension_nocontext.c +++ b/test/egl_has_extension_nocontext.c @@ -38,8 +38,7 @@ #include "egl_common.h" -int -main(int argc, char **argv) +int main(void) { bool pass = true; diff --git a/test/egl_without_glx.c b/test/egl_without_glx.c index c3dcc22..3ba2825 100644 --- a/test/egl_without_glx.c +++ b/test/egl_without_glx.c @@ -87,8 +87,7 @@ override_eglGetError(void) return real_eglGetError(); } -int -main(int argc, char **argv) +int main(void) { bool pass = true; EGLDisplay dpy = get_egl_display_or_skip(); diff --git a/test/glx_alias_prefer_same_name.c b/test/glx_alias_prefer_same_name.c index cfc1344..bdaf367 100644 --- a/test/glx_alias_prefer_same_name.c +++ b/test/glx_alias_prefer_same_name.c @@ -53,17 +53,18 @@ override_GL_glBindTextureEXT(GLenum target); void override_GL_glBindTexture(GLenum target) { + EPOXY_UNUSED(target); last_call = CORE_FUNC_VAL; } void override_GL_glBindTextureEXT(GLenum target) { + EPOXY_UNUSED(target); last_call = EXT_FUNC_VAL; } -int -main(int argc, char **argv) +int main(void) { bool pass = true; diff --git a/test/glx_beginend.c b/test/glx_beginend.c index c68f408..bfed424 100644 --- a/test/glx_beginend.c +++ b/test/glx_beginend.c @@ -89,8 +89,7 @@ test_without_epoxy(void) return true; } -int -main(int argc, char **argv) +int main(void) { bool pass = true; diff --git a/test/glx_common.c b/test/glx_common.c index fda1602..d1e5954 100644 --- a/test/glx_common.c +++ b/test/glx_common.c @@ -72,6 +72,8 @@ get_glx_window(Display *dpy, XVisualInfo *visinfo, bool map) Window root_win = RootWindow(dpy, screen); Window win; + EPOXY_UNUSED(map); + window_attr.background_pixel = 0; window_attr.border_pixel = 0; window_attr.colormap = XCreateColormap(dpy, root_win, @@ -119,7 +121,7 @@ get_fbconfig_for_visinfo(Display *dpy, XVisualInfo *visinfo) if (glXGetFBConfigAttrib(dpy, configs[i], GLX_VISUAL_ID, &v)) continue; - if (v == visinfo->visualid) { + if (v == (int)visinfo->visualid) { ret = configs[i]; break; } diff --git a/test/glx_gles2.c b/test/glx_gles2.c index 969d26b..20debbb 100644 --- a/test/glx_gles2.c +++ b/test/glx_gles2.c @@ -46,6 +46,7 @@ override_GLES2_glCreateShader(GLenum target); GLuint override_GLES2_glCreateShader(GLenum target) { + EPOXY_UNUSED(target); return 0; } @@ -60,8 +61,7 @@ override_GLES2_glGenQueries(GLsizei n, GLuint *ids) ids[i] = 0; } -int -main(int argc, char **argv) +int main(void) { bool pass = true; XVisualInfo *vis; diff --git a/test/glx_glxgetprocaddress_nocontext.c b/test/glx_glxgetprocaddress_nocontext.c index 2182215..357aa15 100644 --- a/test/glx_glxgetprocaddress_nocontext.c +++ b/test/glx_glxgetprocaddress_nocontext.c @@ -39,8 +39,7 @@ static Display *dpy; -int -main(int argc, char **argv) +int main(void) { bool pass = true; void *func; diff --git a/test/glx_has_extension_nocontext.c b/test/glx_has_extension_nocontext.c index 2f87ac3..dde0acb 100644 --- a/test/glx_has_extension_nocontext.c +++ b/test/glx_has_extension_nocontext.c @@ -39,8 +39,7 @@ static Display *dpy; -int -main(int argc, char **argv) +int main(void) { bool pass = true; diff --git a/test/glx_public_api.c b/test/glx_public_api.c index e38d260..a99eaeb 100644 --- a/test/glx_public_api.c +++ b/test/glx_public_api.c @@ -107,8 +107,7 @@ test_glx_extension_supported(void) return true; } -int -main(int argc, char **argv) +int main(void) { bool pass = true; diff --git a/test/glx_public_api_core.c b/test/glx_public_api_core.c index 29252ec..1dcc36d 100644 --- a/test/glx_public_api_core.c +++ b/test/glx_public_api_core.c @@ -130,8 +130,7 @@ test_glx_version(void) return true; } -int -main(int argc, char **argv) +int main(void) { bool pass = true; XVisualInfo *visinfo; diff --git a/test/glx_static.c b/test/glx_static.c index d528a60..acf1644 100644 --- a/test/glx_static.c +++ b/test/glx_static.c @@ -42,8 +42,7 @@ #include "glx_common.h" -int -main(int argc, char **argv) +int main(void) { bool pass = true; int val; diff --git a/test/headerguards.c b/test/headerguards.c index 866b506..732a0b9 100644 --- a/test/headerguards.c +++ b/test/headerguards.c @@ -21,40 +21,31 @@ * IN THE SOFTWARE. */ -#include - #include -#ifdef BUILD_EGL -#include -#include -#endif - -#ifdef BUILD_GLX -#include -#include +#if EPOXY_SUPPORT_EGL + #include + #include #endif -#ifdef BUILD_EGL -#include -#include -#include -#include +#if EPOXY_SUPPORT_GLX + #include + #include #endif -#ifdef BUILD_GLX -#ifdef __APPLE__ -#include -#include -#else -#include -#include -#endif -#include -#include +#if EPOXY_SUPPORT_GLX + #ifdef __APPLE__ + #include + #include + #else + #include + #include + #endif + #include + #include #endif -int main(int argc, char **argv) +int main(void) { return 0; } diff --git a/test/khronos_typedefs_nonepoxy.c b/test/khronos_typedefs_nonepoxy.c index 5386101..56ee814 100644 --- a/test/khronos_typedefs_nonepoxy.c +++ b/test/khronos_typedefs_nonepoxy.c @@ -24,12 +24,9 @@ #include #include -#include "config.h" #include "khronos_typedefs.h" -#ifdef HAVE_KHRPLATFORM_H - -#include +#include "epoxy/khrplatform.h" #define GET_SIZE(type) sizes[type ## _slot] = sizeof(type) @@ -53,19 +50,3 @@ get_system_typedef_sizes(uint32_t *sizes) GET_SIZE(khronos_stime_nanoseconds_t); GET_SIZE(khronos_boolean_enum_t); } - -#else /* !HAVE_KHRPLATFORM_H */ - -#ifndef _MSC_VER -/* Don't care -- this is a conditional case in test code. */ -#pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn" -#endif - -void -get_system_typedef_sizes(uint32_t *sizes) -{ - fprintf(stderr, "./configure failed to find khrplatform.h\n"); - exit(77); -} - -#endif diff --git a/test/miscdefines.c b/test/miscdefines.c index e4bc79a..89a8c87 100644 --- a/test/miscdefines.c +++ b/test/miscdefines.c @@ -23,11 +23,11 @@ #include -#ifdef BUILD_EGL +#if EPOXY_SUPPORT_EGL #include #endif -#ifdef BUILD_GLX +#if EPOXY_SUPPORT_GLX #include #endif @@ -61,7 +61,7 @@ /* Do we want to export GL_GLEXT_VERSION? */ -int main(int argc, char **argv) +int main(void) { return 0; } diff --git a/test/wgl_common.c b/test/wgl_common.c index 97b69ed..7d700ab 100644 --- a/test/wgl_common.c +++ b/test/wgl_common.c @@ -85,8 +85,8 @@ window_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) void make_window_and_test(int (*callback)(HDC hdc)) { - const char *class_name = "epoxy"; - const char *window_name = "epoxy"; + LPCTSTR class_name = TEXT("epoxy"); + LPCTSTR window_name = TEXT("epoxy"); int width = 150; int height = 150; HWND hwnd; diff --git a/test/wgl_core_and_exts.c b/test/wgl_core_and_exts.c index bbb2645..c909541 100644 --- a/test/wgl_core_and_exts.c +++ b/test/wgl_core_and_exts.c @@ -21,7 +21,6 @@ * IN THE SOFTWARE. */ -#include #include #include "wgl_common.h" @@ -71,8 +70,7 @@ test_function(HDC hdc) return !pass; } -int -main(int argc, char **argv) +int main() { make_window_and_test(test_function); diff --git a/test/wgl_per_context_funcptrs.c b/test/wgl_per_context_funcptrs.c index c76c7b3..4e5f3fb 100644 --- a/test/wgl_per_context_funcptrs.c +++ b/test/wgl_per_context_funcptrs.c @@ -35,7 +35,6 @@ * regardless. */ -#include #include #include @@ -57,6 +56,7 @@ OVERRIDE_API (PROC) override_wglGetProcAddress(LPCSTR name); OVERRIDE_API (GLuint) override_glCreateShader_ctx1(GLenum target) { + EPOXY_UNUSED(target); if (current_context != ctx1) { fprintf(stderr, "ctx1 called while other context current\n"); pass = false; @@ -67,6 +67,7 @@ override_glCreateShader_ctx1(GLenum target) OVERRIDE_API (GLuint) override_glCreateShader_ctx2(GLenum target) { + EPOXY_UNUSED(target); if (current_context != ctx2) { fprintf(stderr, "ctx2 called while other context current\n"); pass = false; @@ -156,8 +157,7 @@ test_function(HDC hdc) return !pass; } -int -main(int argc, char **argv) +int main() { make_window_and_test(test_function); diff --git a/test/wgl_usefontbitmaps.c b/test/wgl_usefontbitmaps.c index 3287b65..b40f573 100644 --- a/test/wgl_usefontbitmaps.c +++ b/test/wgl_usefontbitmaps.c @@ -21,7 +21,6 @@ * IN THE SOFTWARE. */ -#include #include #include "wgl_common.h" @@ -48,7 +47,7 @@ test_function(HDC hdc) /* First, use the #ifdeffed variant of the function */ wglUseFontBitmaps(hdc, 0, 255, dlist[1]); glListBase(dlist[1]); - glCallLists(strlen(string), GL_UNSIGNED_BYTE, string); + glCallLists((GLsizei)strlen(string), GL_UNSIGNED_BYTE, string); /* Now, use the specific version, manually. */ #ifdef UNICODE @@ -57,7 +56,7 @@ test_function(HDC hdc) wglUseFontBitmapsA(hdc, 0, 255, dlist[2]); #endif glListBase(dlist[2]); - glCallLists(strlen(string), GL_UNSIGNED_BYTE, string); + glCallLists((GLsizei)strlen(string), GL_UNSIGNED_BYTE, string); wglMakeCurrent(NULL, NULL); wglDeleteContext(ctx); @@ -65,8 +64,7 @@ test_function(HDC hdc) return !pass; } -int -main(int argc, char **argv) +int main() { make_window_and_test(test_function);