Index: gap-4.12.1/src/gaptime.c
===================================================================
--- gap-4.12.1.orig/src/gaptime.c
+++ gap-4.12.1/src/gaptime.c
@@ -36,7 +36,7 @@
 #include <sys/resource.h>
 #endif
 
-#ifdef __MACH__ // macOS
+#if defined(__APPLE__) && defined(__MACH__) // macOS
 #include <mach/mach_time.h>
 #endif
 
@@ -88,7 +88,7 @@ Int8 SyNanosecondsSinceEpoch(void)
 {
     Int8 res;
 
-#if defined(__MACH__)
+#if defined(__APPLE__) && defined(__MACH__) // macOS
     static mach_timebase_info_data_t timeinfo;
     if (timeinfo.denom == 0) {
         (void)mach_timebase_info(&timeinfo);
@@ -148,7 +148,7 @@ static Int8 SyNanosecondsSinceEpochResol
 {
     Int8 res;
 
-#if defined(__MACH__)
+#if defined(__APPLE__) && defined(__MACH__) // macOS
     static mach_timebase_info_data_t timeinfo;
     if (timeinfo.denom == 0) {
         (void)mach_timebase_info(&timeinfo);
@@ -256,7 +256,7 @@ static Obj FuncNanosecondsSinceEpochInfo
     const char * method = "unsupported";
     Int          monotonic = 0;
 
-#if defined(__MACH__)
+#if defined(__APPLE__) && defined(__MACH__) // macOS
     method = "mach_absolute_time";
     monotonic = 1;
 #elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
