0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-26 16:11:02 +08:00

Add support for building with Apple LLVM clang version < 8.0 (#82)

* Add support for building with pre 2016 Apple LLVM clang

* Automatically detect Apple clang that do not support thread_local

* Clarify clang thread_local support code comment
This commit is contained in:
Mika Rautio 2017-11-20 19:23:15 +02:00 committed by Victor Zarubkin
parent 86be4c9d59
commit e5fd86f9c8
5 changed files with 10 additions and 4 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.12.1) cmake_minimum_required(VERSION 3.0)
project(easy_profiler CXX) project(easy_profiler CXX)
set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)

View File

@ -15,6 +15,10 @@ if (NOT WIN32)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.3") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.3")
set(NO_CXX11_THREAD_LOCAL_SUPPORT TRUE) set(NO_CXX11_THREAD_LOCAL_SUPPORT TRUE)
endif () endif ()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0")
set(NO_CXX11_THREAD_LOCAL_SUPPORT TRUE)
endif ()
endif () endif ()
# TODO: Check thread_local keyword support for other compilers for Unix # TODO: Check thread_local keyword support for other compilers for Unix

View File

@ -88,8 +88,8 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Clang Compiler // Clang Compiler
# if (__clang_major__ == 3 && __clang_minor__ < 3) || (__clang_major__ < 3) # if (__clang_major__ == 3 && __clang_minor__ < 3) || (__clang_major__ < 3) || (defined __APPLE_CC__ && __APPLE_CC__ < 8000)
// There is no support for C++11 thread_local keyword prior to clang 3.3. Use __thread instead. // There is no support for C++11 thread_local keyword prior to clang 3.3 and Apple LLVM clang 8.0. Use __thread instead.
# define EASY_THREAD_LOCAL __thread # define EASY_THREAD_LOCAL __thread
# endif # endif

View File

@ -41,7 +41,8 @@ The Apache License, Version 2.0 (the "License");
**/ **/
#include "nonscoped_block.h" #include "nonscoped_block.h"
#include <string.h> #include <cstring>
#include <cstdlib>
NonscopedBlock::NonscopedBlock(const profiler::BaseBlockDescriptor* _desc, const char* _runtimeName, bool) NonscopedBlock::NonscopedBlock(const profiler::BaseBlockDescriptor* _desc, const char* _runtimeName, bool)
: profiler::Block(_desc, _runtimeName, false), m_runtimeName(nullptr) : profiler::Block(_desc, _runtimeName, false), m_runtimeName(nullptr)

View File

@ -46,6 +46,7 @@ The Apache License, Version 2.0 (the "License");
#include "nonscoped_block.h" #include "nonscoped_block.h"
#include <list> #include <list>
#include <algorithm> #include <algorithm>
#include <cstdlib>
#ifdef max #ifdef max
#undef max #undef max