@@ -23,10 +23,10 @@ extern "C"
2323
2424#include "rcutils/time.h"
2525
26- #if defined(__MACH__ )
26+ #if defined(__MACH__ ) && defined( __APPLE__ )
2727#include <mach/clock.h>
2828#include <mach/mach.h>
29- #endif // defined(__MACH__)
29+ #endif // defined(__MACH__) && defined(__APPLE__)
3030#include <math.h>
3131
3232#if defined(__ZEPHYR__ )
@@ -40,13 +40,13 @@ extern "C"
4040#include "rcutils/allocator.h"
4141#include "rcutils/error_handling.h"
4242
43- #if !defined(__MACH__ ) // Assume clock_get_time is available on OS X.
43+ #if !defined(__MACH__ ) && !defined( __APPLE__ ) // Assume clock_get_time is available on OS X.
4444// This id an appropriate check for clock_gettime() according to:
4545// http://man7.org/linux/man-pages/man2/clock_gettime.2.html
4646# if !defined(_POSIX_TIMERS ) || !_POSIX_TIMERS
4747# error no monotonic clock function available
4848# endif // !defined(_POSIX_TIMERS) || !_POSIX_TIMERS
49- #endif // !defined(__MACH__)
49+ #endif // !defined(__MACH__) && !defined(__APPLE__)
5050
5151#define __WOULD_BE_NEGATIVE (seconds , subseconds ) (seconds < 0 || (subseconds < 0 && seconds == 0))
5252
@@ -55,15 +55,15 @@ rcutils_system_time_now(rcutils_time_point_value_t * now)
5555{
5656 RCUTILS_CHECK_ARGUMENT_FOR_NULL (now , RCUTILS_RET_INVALID_ARGUMENT );
5757 struct timespec timespec_now ;
58- #if defined(__MACH__ )
58+ #if defined(__MACH__ ) && defined( __APPLE__ )
5959 // On macOS, use clock_gettime(CLOCK_REALTIME), which matches
6060 // the clang implementation
6161 // (https://github.com/llvm/llvm-project/blob/baebe12ad0d6f514cd33e418d6504075d3e79c0a/libcxx/src/chrono.cpp)
6262 clock_gettime (CLOCK_REALTIME , & timespec_now );
63- #else // defined(__MACH__)
63+ #else // defined(__MACH__) && defined(__APPLE__)
6464 // Otherwise use clock_gettime.
6565 clock_gettime (CLOCK_REALTIME , & timespec_now );
66- #endif // defined(__MACH__)
66+ #endif // defined(__MACH__) && defined(__APPLE__)
6767 if (__WOULD_BE_NEGATIVE (timespec_now .tv_sec , timespec_now .tv_nsec )) {
6868 RCUTILS_SET_ERROR_MSG ("unexpected negative time" );
6969 return RCUTILS_RET_ERROR ;
@@ -78,15 +78,15 @@ rcutils_steady_time_now(rcutils_time_point_value_t * now)
7878 RCUTILS_CHECK_ARGUMENT_FOR_NULL (now , RCUTILS_RET_INVALID_ARGUMENT );
7979 // If clock_gettime is available or on OS X, use a timespec.
8080 struct timespec timespec_now ;
81- #if defined(__MACH__ )
81+ #if defined(__MACH__ ) && defined( __APPLE__ )
8282 // On macOS, use clock_gettime(CLOCK_MONOTONIC_RAW), which matches
8383 // the clang implementation
8484 // (https://github.com/llvm/llvm-project/blob/baebe12ad0d6f514cd33e418d6504075d3e79c0a/libcxx/src/chrono.cpp)
8585 clock_gettime (CLOCK_MONOTONIC_RAW , & timespec_now );
86- #else // defined(__MACH__)
86+ #else // defined(__MACH__) && defined(__APPLE__)
8787 // Otherwise use clock_gettime.
8888 clock_gettime (CLOCK_MONOTONIC , & timespec_now );
89- #endif // defined(__MACH__)
89+ #endif // defined(__MACH__) && defined(__APPLE__)
9090 if (__WOULD_BE_NEGATIVE (timespec_now .tv_sec , timespec_now .tv_nsec )) {
9191 RCUTILS_SET_ERROR_MSG ("unexpected negative time" );
9292 return RCUTILS_RET_ERROR ;
0 commit comments