Skip to content

Commit

Permalink
[Build] Update CMake to use C++11 and fix MacOS warnings (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesEggleton authored Apr 11, 2020
1 parent 39f7a37 commit 7b2e817
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ endif()

target_link_libraries(libocca ${LIBOCCA_LIBRARIES})

target_compile_features(libocca PUBLIC cxx_std_11)
target_compile_options(libocca PRIVATE -Wall -Wextra -Wno-c++11-extensions -Wno-unused-parameter)

install(TARGETS libocca DESTINATION lib)
16 changes: 10 additions & 6 deletions src/tools/sys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,9 @@ namespace occa {
return (double) (ct.tv_sec + (1.0e-9 * ct.tv_nsec));
#elif (OCCA_OS == OCCA_MACOS_OS)
# ifdef __clang__
uint64_t ct;
ct = mach_absolute_time();
uint64_t nanoseconds = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);

const Nanoseconds ct2 = AbsoluteToNanoseconds(*(AbsoluteTime *) &ct);

return ((double) 1.0e-9) * ((double) ( *((uint64_t*) &ct2) ));
return 1.0e-9 * nanoseconds;
# else
clock_serv_t cclock;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
Expand Down Expand Up @@ -366,7 +363,14 @@ namespace occa {

int getTID() {
#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))
return syscall(SYS_gettid);
#if OCCA_OS == OCCA_MACOS_OS & (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12)
uint64_t tid64;
pthread_threadid_np(NULL, &tid64);
pid_t tid = (pid_t)tid64;
#else
pid_t tid = syscall(SYS_gettid);
#endif
return tid;
#else
return GetCurrentThreadId();
#endif
Expand Down

0 comments on commit 7b2e817

Please sign in to comment.