2015-12-10 06:46:49 +08:00
|
|
|
|
|
|
|
CHECK_CXX_SOURCE_COMPILES("
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include <Intrin.h> /* Workaround for PR19898. */
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
int main() {
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
volatile LONG val = 1;
|
|
|
|
MemoryBarrier();
|
|
|
|
InterlockedCompareExchange(&val, 0, 1);
|
|
|
|
InterlockedIncrement(&val);
|
|
|
|
InterlockedDecrement(&val);
|
|
|
|
#else
|
|
|
|
volatile unsigned long val = 1;
|
|
|
|
__sync_synchronize();
|
|
|
|
__sync_val_compare_and_swap(&val, 1, 0);
|
|
|
|
__sync_add_and_fetch(&val, 1);
|
|
|
|
__sync_sub_and_fetch(&val, 1);
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" COMPILER_RT_TARGET_HAS_ATOMICS)
|
|
|
|
|
2016-06-06 11:17:58 +08:00
|
|
|
CHECK_CXX_SOURCE_COMPILES("
|
|
|
|
#if defined(__linux__)
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#include <fcntl.h>
|
|
|
|
int fd;
|
|
|
|
int main() {
|
|
|
|
struct flock s_flock;
|
|
|
|
|
|
|
|
s_flock.l_type = F_WRLCK;
|
|
|
|
fcntl(fd, F_SETLKW, &s_flock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
" COMPILER_RT_TARGET_HAS_FCNTL_LCK)
|
|
|
|
|
2016-08-27 04:52:22 +08:00
|
|
|
add_compiler_rt_component(profile)
|
2014-02-18 17:33:45 +08:00
|
|
|
|
2014-04-23 02:49:32 +08:00
|
|
|
set(PROFILE_SOURCES
|
|
|
|
GCDAProfiling.c
|
|
|
|
InstrProfiling.c
|
2015-12-11 04:24:09 +08:00
|
|
|
InstrProfilingValue.c
|
2014-04-23 02:49:32 +08:00
|
|
|
InstrProfilingBuffer.c
|
|
|
|
InstrProfilingFile.c
|
2016-03-04 02:54:46 +08:00
|
|
|
InstrProfilingMerge.c
|
|
|
|
InstrProfilingMergeFile.c
|
2015-11-19 05:08:03 +08:00
|
|
|
InstrProfilingWriter.c
|
2014-04-23 02:49:32 +08:00
|
|
|
InstrProfilingPlatformDarwin.c
|
2015-10-14 02:40:00 +08:00
|
|
|
InstrProfilingPlatformLinux.c
|
2014-04-23 02:49:32 +08:00
|
|
|
InstrProfilingPlatformOther.c
|
2015-07-10 01:21:52 +08:00
|
|
|
InstrProfilingRuntime.cc
|
2016-01-07 00:55:21 +08:00
|
|
|
InstrProfilingUtil.c)
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
list(APPEND PROFILE_SOURCES WindowsMMap.c)
|
|
|
|
endif()
|
2014-03-20 11:57:33 +08:00
|
|
|
|
2015-11-14 06:33:07 +08:00
|
|
|
if(UNIX)
|
|
|
|
set(EXTRA_FLAGS
|
|
|
|
-fPIC
|
|
|
|
-Wno-pedantic)
|
|
|
|
endif()
|
|
|
|
|
2015-12-10 06:46:49 +08:00
|
|
|
if(COMPILER_RT_TARGET_HAS_ATOMICS)
|
|
|
|
set(EXTRA_FLAGS
|
|
|
|
${EXTRA_FLAGS}
|
|
|
|
-DCOMPILER_RT_HAS_ATOMICS=1)
|
|
|
|
endif()
|
|
|
|
|
2016-06-06 11:17:58 +08:00
|
|
|
if(COMPILER_RT_TARGET_HAS_FCNTL_LCK)
|
|
|
|
set(EXTRA_FLAGS
|
|
|
|
${EXTRA_FLAGS}
|
|
|
|
-DCOMPILER_RT_HAS_FCNTL_LCK=1)
|
|
|
|
endif()
|
|
|
|
|
2016-06-18 02:12:50 +08:00
|
|
|
# This appears to be a C-only warning banning the use of locals in aggregate
|
|
|
|
# initializers. All other compilers accept this, though.
|
|
|
|
# nonstandard extension used : 'identifier' : cannot be initialized using address of automatic variable
|
|
|
|
append_list_if(COMPILER_RT_HAS_WD4221_FLAG /wd4221 EXTRA_FLAGS)
|
|
|
|
|
2014-04-23 02:49:32 +08:00
|
|
|
if(APPLE)
|
2015-08-26 03:53:09 +08:00
|
|
|
add_compiler_rt_runtime(clang_rt.profile
|
|
|
|
STATIC
|
2015-10-01 05:23:22 +08:00
|
|
|
OS ${PROFILE_SUPPORTED_OS}
|
2015-08-26 03:53:09 +08:00
|
|
|
ARCHS ${PROFILE_SUPPORTED_ARCH}
|
2016-06-09 00:21:35 +08:00
|
|
|
CFLAGS ${EXTRA_FLAGS}
|
2015-08-26 03:53:09 +08:00
|
|
|
SOURCES ${PROFILE_SOURCES}
|
|
|
|
PARENT_TARGET profile)
|
2013-03-25 22:20:11 +08:00
|
|
|
else()
|
2015-08-26 03:53:09 +08:00
|
|
|
add_compiler_rt_runtime(clang_rt.profile
|
|
|
|
STATIC
|
|
|
|
ARCHS ${PROFILE_SUPPORTED_ARCH}
|
2015-11-14 06:33:07 +08:00
|
|
|
CFLAGS ${EXTRA_FLAGS}
|
2015-08-26 03:53:09 +08:00
|
|
|
SOURCES ${PROFILE_SOURCES}
|
|
|
|
PARENT_TARGET profile)
|
2013-03-19 17:17:35 +08:00
|
|
|
endif()
|