From c542bd114090753f5fc6f55e68605e1fd3bbd070 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 10 Nov 2014 15:06:56 -0500 Subject: [PATCH 1/2] repair undef None GLX wrapper, pass 0 instead of None to GLX functions --- include/mbgl/platform/default/headless_view.hpp | 2 +- platform/default/headless_display.cpp | 2 +- platform/default/headless_view.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/mbgl/platform/default/headless_view.hpp b/include/mbgl/platform/default/headless_view.hpp index f599dde27..9d8acf70f 100644 --- a/include/mbgl/platform/default/headless_view.hpp +++ b/include/mbgl/platform/default/headless_view.hpp @@ -5,7 +5,7 @@ #define MBGL_USE_CGL 1 #else #define GL_GLEXT_PROTOTYPES -#include +#include #define MBGL_USE_GLX 1 #endif diff --git a/platform/default/headless_display.cpp b/platform/default/headless_display.cpp index 409fcbf05..ada48b864 100644 --- a/platform/default/headless_display.cpp +++ b/platform/default/headless_display.cpp @@ -48,7 +48,7 @@ HeadlessDisplay::HeadlessDisplay() { // We're creating a dummy pbuffer anyway that we're not using. static int pixelFormat[] = { GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, - None + 0 }; int configs = 0; diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp index 687f3ecf7..1f5a0ec98 100644 --- a/platform/default/headless_view.cpp +++ b/platform/default/headless_view.cpp @@ -107,7 +107,7 @@ GLXContext createCoreProfile(Display *dpy, GLXFBConfig fbconfig) { const int context_flags[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, core_profile_versions[i].major, GLX_CONTEXT_MINOR_VERSION_ARB, core_profile_versions[i].minor, - None + 0 }; ctx = glXCreateContextAttribsARB(dpy, fbconfig, 0, True, context_flags); if (context_creation_failed) { @@ -172,7 +172,7 @@ void HeadlessView::createContext() { int pbuffer_attributes[] = { GLX_PBUFFER_WIDTH, 8, GLX_PBUFFER_HEIGHT, 8, - None + 0 }; glx_pbuffer = glXCreatePbuffer(x_display, fb_configs[0], pbuffer_attributes); #endif From 27cf24171a014b63e139e7fc77422753beac44e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 12 Nov 2014 12:12:01 +0100 Subject: [PATCH 2/2] check library versions against header symbols in static initialization function fixes #580 --- platform/default/http_request_baton_curl.cpp | 15 ++++++ platform/default/image.cpp | 14 +++++ src/map/map.cpp | 55 ++++++++++++++++++++ 3 files changed, 84 insertions(+) diff --git a/platform/default/http_request_baton_curl.cpp b/platform/default/http_request_baton_curl.cpp index b8b4bac5f..02e9497c9 100644 --- a/platform/default/http_request_baton_curl.cpp +++ b/platform/default/http_request_baton_curl.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -9,6 +10,20 @@ #include #include + +// Check curl library version. +const static bool curl_version_check = []() { + const auto version = curl_version_info(CURLVERSION_NOW); + if (version->version_num != LIBCURL_VERSION_NUM) { + throw std::runtime_error(mbgl::util::sprintf<96>( + "libcurl version mismatch: headers report %d.%d.%d, but library reports %d.%d.%d", + (LIBCURL_VERSION_NUM >> 16) & 0xFF, (LIBCURL_VERSION_NUM >> 8) & 0xFF, LIBCURL_VERSION_NUM & 0xFF, + (version->version_num >> 16) & 0xFF, (version->version_num >> 8) & 0xFF, version->version_num & 0xFF)); + } + return true; +}(); + + // This file contains code from http://curl.haxx.se/libcurl/c/multi-uv.html: /*************************************************************************** diff --git a/platform/default/image.cpp b/platform/default/image.cpp index 68d178691..bf119fee0 100644 --- a/platform/default/image.cpp +++ b/platform/default/image.cpp @@ -1,4 +1,5 @@ #include +#include #include @@ -8,6 +9,19 @@ #include +// Check png library version. +const static bool png_version_check = []() { + const png_uint_32 version = png_access_version_number(); + if (version != PNG_LIBPNG_VER) { + throw std::runtime_error(mbgl::util::sprintf<96>( + "libpng version mismatch: headers report %d.%d.%d, but library reports %d.%d.%d", + PNG_LIBPNG_VER / 10000, (PNG_LIBPNG_VER / 100) % 100, PNG_LIBPNG_VER % 100, + version / 10000, (version / 100) % 100, version % 100)); + } + return true; +}(); + + namespace mbgl { namespace util { diff --git a/src/map/map.cpp b/src/map/map.cpp index d0a279b64..6e9e47fd5 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -28,6 +29,60 @@ #define _USE_MATH_DEFINES #include +#include + +// Check libuv library version. +const static bool uv_version_check = []() { + const unsigned int version = uv_version(); + const unsigned int major = (version >> 16) & 0xFF; + const unsigned int minor = (version >> 8) & 0xFF; + const unsigned int patch = version & 0xFF; + +#ifndef UV_VERSION_PATCH + // 0.10 doesn't have UV_VERSION_PATCH defined, so we "fake" it by using the library patch level. + const unsigned int UV_VERSION_PATCH = version & 0xFF; +#endif + + if (major != UV_VERSION_MAJOR || minor != UV_VERSION_MINOR || patch != UV_VERSION_PATCH) { + throw std::runtime_error(mbgl::util::sprintf<96>( + "libuv version mismatch: headers report %d.%d.%d, but library reports %d.%d.%d", UV_VERSION_MAJOR, + UV_VERSION_MINOR, UV_VERSION_PATCH, major, minor, patch)); + } + return true; +}(); + + +#include +// Check zlib library version. +const static bool zlib_version_check = []() { + const char *const version = zlibVersion(); + if (version[0] != ZLIB_VERSION[0]) { + throw std::runtime_error(mbgl::util::sprintf<96>( + "zlib version mismatch: headers report %s, but library reports %s", ZLIB_VERSION, version)); + } + + return true; +}(); + + +#include +// Check sqlite3 library version. +const static bool sqlite_version_check = []() { + if (sqlite3_libversion_number() != SQLITE_VERSION_NUMBER) { + throw std::runtime_error(mbgl::util::sprintf<96>( + "sqlite3 libversion mismatch: headers report %d, but library reports %d", + SQLITE_VERSION_NUMBER, sqlite3_libversion_number())); + } + if (strcmp(sqlite3_sourceid(), SQLITE_SOURCE_ID) != 0) { + throw std::runtime_error(mbgl::util::sprintf<256>( + "sqlite3 sourceid mismatch: headers report \"%s\", but library reports \"%s\"", + SQLITE_SOURCE_ID, sqlite3_sourceid())); + } + + return true; +}(); + + using namespace mbgl; Map::Map(View& view_)