summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndrew Kaster <andrewdkaster@gmail.com>2020-12-27 15:38:32 -0700
committerAndreas Kling <kling@serenityos.org>2020-12-28 19:35:32 +0100
commit1219c6524905874c96ca8dbd9bc2d69960994d9b (patch)
tree32ce6c58c4e3cdeb9cea96b85e2f8a423c6cd884 /AK
parent3bdaba0b289642c8d2c50798c8ddbb842307e308 (diff)
downloadserenity-1219c6524905874c96ca8dbd9bc2d69960994d9b.zip
AK: Add CLOCK_*_COARSE aliases for darwin and BSD variants
The coarse clocks in time.h are a linux extension that we've adopted. MacOS and the BSDs don't have it, so we need an alias in a platform header for Lagom builds.
Diffstat (limited to 'AK')
-rw-r--r--AK/Platform.h14
-rw-r--r--AK/Time.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/AK/Platform.h b/AK/Platform.h
index 1b02a3b500..440490c0b3 100644
--- a/AK/Platform.h
+++ b/AK/Platform.h
@@ -34,6 +34,15 @@
# define AK_ARCH_X86_64 1
#endif
+#if defined(__APPLE__) && defined(__MACH__)
+# define AK_OS_MACOS
+# define AK_OS_BSD_GENERIC
+#endif
+
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+# define AK_OS_BSD_GENERIC
+#endif
+
#define ARCH(arch) (defined(AK_ARCH_##arch) && AK_ARCH_##arch)
#ifdef ALWAYS_INLINE
@@ -88,4 +97,9 @@ ALWAYS_INLINE int count_trailing_zeroes_32(unsigned int val)
}
return 0;
#endif
+
+#ifdef AK_OS_BSD_GENERIC
+# define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
+# define CLOCK_REALTIME_COARSE CLOCK_REALTIME
+#endif
}
diff --git a/AK/Time.h b/AK/Time.h
index a919f36f5e..8741d999e8 100644
--- a/AK/Time.h
+++ b/AK/Time.h
@@ -26,6 +26,8 @@
#pragma once
+#include <AK/Platform.h>
+
namespace AK {
// Month and day start at 1. Month must be >= 1 and <= 12.