base: Fix fiber compilation issue for Mac OS

Mac OS has deprecated the use of ucontext and at the moment we are
using a workaround to enable it. A side-effect is that the code is
marked as _POSIX_C_SOURCE and consequently <sys/mman.h> requires the
code to be also marked as _DARWIN_C_SOURCE to include the definition
of MAP_ANONYMOUS.

Change-Id: I65550d11a0a21cd36d832a7de6320e7e3f332a9d
Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/14817
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
diff --git a/src/base/fiber.cc b/src/base/fiber.cc
index af63216..177459a 100644
--- a/src/base/fiber.cc
+++ b/src/base/fiber.cc
@@ -33,6 +33,14 @@
 #include <valgrind/valgrind.h>
 #endif
 
+// Mac OS requires _DARWIN_C_SOURCE if _POSIX_C_SOURCE is defined,
+// otherwise it will mask the definition of MAP_ANONYMOUS.
+// _POSIX_C_SOURCE is already defined by including <ucontext.h> in
+// base/fiber.hh
+#if defined(__APPLE__) && defined(__MACH__)
+#define _DARWIN_C_SOURCE
+#endif
+
 #include <sys/mman.h>
 #include <unistd.h>