diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 58f81fd3..9abb6086 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -51,6 +51,7 @@ Pierre Phaneuf Radoslav Yovchev Ray Glover Shuo Chen +Tom Madams Yixuan Qiu Yusuke Suzuki Tobias Ulvgård diff --git a/src/internal_macros.h b/src/internal_macros.h index 8dd9f87b..94288745 100644 --- a/src/internal_macros.h +++ b/src/internal_macros.h @@ -45,6 +45,8 @@ #define BENCHMARK_OS_NACL 1 #elif defined(EMSCRIPTEN) #define BENCHMARK_OS_EMSCRIPTEN 1 +#elif defined(__rtems__) +#define BENCHMARK_OS_RTEMS 1 #endif #if !__has_feature(cxx_exceptions) && !defined(__cpp_exceptions) \ diff --git a/src/timers.cc b/src/timers.cc index 8d56e8ad..817272d0 100644 --- a/src/timers.cc +++ b/src/timers.cc @@ -158,6 +158,10 @@ double ThreadCPUUsage() { #elif defined(BENCHMARK_OS_EMSCRIPTEN) // Emscripten doesn't support traditional threads return ProcessCPUUsage(); +#elif defined(BENCHMARK_OS_RTEMS) + // RTEMS doesn't support CLOCK_THREAD_CPUTIME_ID. See + // https://github.com/RTEMS/rtems/blob/master/cpukit/posix/src/clockgettime.c + return ProcessCPUUsage(); #elif defined(CLOCK_THREAD_CPUTIME_ID) struct timespec ts; if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) == 0) return MakeTime(ts);