aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-12-07 18:03:23 -0800
committerRob Landley <rob@landley.net>2018-12-07 21:07:39 -0600
commitfcbe8c639d60c4ed844204e7291746220de0b2ee (patch)
tree92b8905b435dc2d1db7ff47b96596ca50939b54f
parent66723ec39d978365f1e46840903ae20c33637c88 (diff)
downloadtoybox-fcbe8c639d60c4ed844204e7291746220de0b2ee.tar.gz
macOS: fix code using POSIX 2008 `st_[acm]tim` fields.
Hopefully they'll fix this properly at some point, but until then...
-rw-r--r--lib/portability.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/portability.h b/lib/portability.h
index 60d40498..48cb490a 100644
--- a/lib/portability.h
+++ b/lib/portability.h
@@ -7,6 +7,17 @@
// For musl
#define _ALL_SOURCE
+#ifdef __APPLE__
+// macOS 10.13 doesn't have the POSIX 2008 direct access to timespec in
+// struct stat, but we can ask it to give us something equivalent...
+// (This must come before any #include!)
+#define _DARWIN_C_SOURCE
+// ...and then use macros to paper over the difference.
+#define st_atim st_atimespec
+#define st_ctim st_ctimespec
+#define st_mtim st_mtimespec
+#endif
+
// Test for gcc (using compiler builtin #define)
#ifdef __GNUC__