1*7c3d14c8STreehugger Robot 2*7c3d14c8STreehugger RobotCHECK_CXX_SOURCE_COMPILES(" 3*7c3d14c8STreehugger Robot#ifdef _MSC_VER 4*7c3d14c8STreehugger Robot#include <Intrin.h> /* Workaround for PR19898. */ 5*7c3d14c8STreehugger Robot#include <windows.h> 6*7c3d14c8STreehugger Robot#endif 7*7c3d14c8STreehugger Robotint main() { 8*7c3d14c8STreehugger Robot#ifdef _MSC_VER 9*7c3d14c8STreehugger Robot volatile LONG val = 1; 10*7c3d14c8STreehugger Robot MemoryBarrier(); 11*7c3d14c8STreehugger Robot InterlockedCompareExchange(&val, 0, 1); 12*7c3d14c8STreehugger Robot InterlockedIncrement(&val); 13*7c3d14c8STreehugger Robot InterlockedDecrement(&val); 14*7c3d14c8STreehugger Robot#else 15*7c3d14c8STreehugger Robot volatile unsigned long val = 1; 16*7c3d14c8STreehugger Robot __sync_synchronize(); 17*7c3d14c8STreehugger Robot __sync_val_compare_and_swap(&val, 1, 0); 18*7c3d14c8STreehugger Robot __sync_add_and_fetch(&val, 1); 19*7c3d14c8STreehugger Robot __sync_sub_and_fetch(&val, 1); 20*7c3d14c8STreehugger Robot#endif 21*7c3d14c8STreehugger Robot return 0; 22*7c3d14c8STreehugger Robot } 23*7c3d14c8STreehugger Robot" COMPILER_RT_TARGET_HAS_ATOMICS) 24*7c3d14c8STreehugger Robot 25*7c3d14c8STreehugger RobotCHECK_CXX_SOURCE_COMPILES(" 26*7c3d14c8STreehugger Robot#if defined(__linux__) 27*7c3d14c8STreehugger Robot#include <unistd.h> 28*7c3d14c8STreehugger Robot#endif 29*7c3d14c8STreehugger Robot#include <fcntl.h> 30*7c3d14c8STreehugger Robotint fd; 31*7c3d14c8STreehugger Robotint main() { 32*7c3d14c8STreehugger Robot struct flock s_flock; 33*7c3d14c8STreehugger Robot 34*7c3d14c8STreehugger Robot s_flock.l_type = F_WRLCK; 35*7c3d14c8STreehugger Robot fcntl(fd, F_SETLKW, &s_flock); 36*7c3d14c8STreehugger Robot return 0; 37*7c3d14c8STreehugger Robot} 38*7c3d14c8STreehugger Robot 39*7c3d14c8STreehugger Robot" COMPILER_RT_TARGET_HAS_FCNTL_LCK) 40*7c3d14c8STreehugger Robot 41*7c3d14c8STreehugger Robotadd_custom_target(profile) 42*7c3d14c8STreehugger Robotset_target_properties(profile PROPERTIES FOLDER "Compiler-RT Misc") 43*7c3d14c8STreehugger Robot 44*7c3d14c8STreehugger Robotset(PROFILE_SOURCES 45*7c3d14c8STreehugger Robot GCDAProfiling.c 46*7c3d14c8STreehugger Robot InstrProfiling.c 47*7c3d14c8STreehugger Robot InstrProfilingValue.c 48*7c3d14c8STreehugger Robot InstrProfilingBuffer.c 49*7c3d14c8STreehugger Robot InstrProfilingFile.c 50*7c3d14c8STreehugger Robot InstrProfilingMerge.c 51*7c3d14c8STreehugger Robot InstrProfilingMergeFile.c 52*7c3d14c8STreehugger Robot InstrProfilingWriter.c 53*7c3d14c8STreehugger Robot InstrProfilingPlatformDarwin.c 54*7c3d14c8STreehugger Robot InstrProfilingPlatformLinux.c 55*7c3d14c8STreehugger Robot InstrProfilingPlatformOther.c 56*7c3d14c8STreehugger Robot InstrProfilingRuntime.cc 57*7c3d14c8STreehugger Robot InstrProfilingUtil.c) 58*7c3d14c8STreehugger Robot 59*7c3d14c8STreehugger Robotif(WIN32) 60*7c3d14c8STreehugger Robot list(APPEND PROFILE_SOURCES WindowsMMap.c) 61*7c3d14c8STreehugger Robotendif() 62*7c3d14c8STreehugger Robot 63*7c3d14c8STreehugger Robotif(UNIX) 64*7c3d14c8STreehugger Robot set(EXTRA_FLAGS 65*7c3d14c8STreehugger Robot -fPIC 66*7c3d14c8STreehugger Robot -Wno-pedantic) 67*7c3d14c8STreehugger Robotendif() 68*7c3d14c8STreehugger Robot 69*7c3d14c8STreehugger Robotif(COMPILER_RT_TARGET_HAS_ATOMICS) 70*7c3d14c8STreehugger Robot set(EXTRA_FLAGS 71*7c3d14c8STreehugger Robot ${EXTRA_FLAGS} 72*7c3d14c8STreehugger Robot -DCOMPILER_RT_HAS_ATOMICS=1) 73*7c3d14c8STreehugger Robotendif() 74*7c3d14c8STreehugger Robot 75*7c3d14c8STreehugger Robotif(COMPILER_RT_TARGET_HAS_FCNTL_LCK) 76*7c3d14c8STreehugger Robot set(EXTRA_FLAGS 77*7c3d14c8STreehugger Robot ${EXTRA_FLAGS} 78*7c3d14c8STreehugger Robot -DCOMPILER_RT_HAS_FCNTL_LCK=1) 79*7c3d14c8STreehugger Robotendif() 80*7c3d14c8STreehugger Robot 81*7c3d14c8STreehugger Robot# This appears to be a C-only warning banning the use of locals in aggregate 82*7c3d14c8STreehugger Robot# initializers. All other compilers accept this, though. 83*7c3d14c8STreehugger Robot# nonstandard extension used : 'identifier' : cannot be initialized using address of automatic variable 84*7c3d14c8STreehugger Robotappend_list_if(COMPILER_RT_HAS_WD4221_FLAG /wd4221 EXTRA_FLAGS) 85*7c3d14c8STreehugger Robot 86*7c3d14c8STreehugger Robotif(APPLE) 87*7c3d14c8STreehugger Robot add_compiler_rt_runtime(clang_rt.profile 88*7c3d14c8STreehugger Robot STATIC 89*7c3d14c8STreehugger Robot OS ${PROFILE_SUPPORTED_OS} 90*7c3d14c8STreehugger Robot ARCHS ${PROFILE_SUPPORTED_ARCH} 91*7c3d14c8STreehugger Robot CFLAGS ${EXTRA_FLAGS} 92*7c3d14c8STreehugger Robot SOURCES ${PROFILE_SOURCES} 93*7c3d14c8STreehugger Robot PARENT_TARGET profile) 94*7c3d14c8STreehugger Robotelse() 95*7c3d14c8STreehugger Robot add_compiler_rt_runtime(clang_rt.profile 96*7c3d14c8STreehugger Robot STATIC 97*7c3d14c8STreehugger Robot ARCHS ${PROFILE_SUPPORTED_ARCH} 98*7c3d14c8STreehugger Robot CFLAGS ${EXTRA_FLAGS} 99*7c3d14c8STreehugger Robot SOURCES ${PROFILE_SOURCES} 100*7c3d14c8STreehugger Robot PARENT_TARGET profile) 101*7c3d14c8STreehugger Robotendif() 102*7c3d14c8STreehugger Robot 103*7c3d14c8STreehugger Robotadd_dependencies(compiler-rt profile) 104