]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include: provide MAP_ANONYMOUS on OSX
authorRuediger Meier <ruediger.meier@ga-group.nl>
Thu, 18 Feb 2016 15:37:13 +0000 (16:37 +0100)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Thu, 18 Feb 2016 15:54:05 +0000 (16:54 +0100)
Hope there are no side effect when defining _DARWIN_C_SOURCE
globally.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
configure.ac
include/c.h

index 17917af7b6c94ca97a281da2a034a0c60e75899c..5cee8cfa4ca20e6a973e144253e8a9b32595915c 100644 (file)
@@ -158,11 +158,17 @@ bsd_os=no
 AS_CASE([${host_os}],
   [*linux*],
      [linux_os=yes],
+  [*darwin*],
+     [darwin_os=yes],
   [*bsd*],
      [bsd_os=yes])
 AM_CONDITIONAL([LINUX], [test "x$linux_os" = xyes])
+AM_CONDITIONAL([DARWIN], [test "x$darwin_os" = xyes])
 AM_CONDITIONAL([BSD], [test "x$bsd_os" = xyes])
 
+AS_IF([test  "x$darwin_os" = xyes], [
+  AC_DEFINE([_DARWIN_C_SOURCE], [1], [Enable MAP_ANON in sys/mman.h on Mac OS X])
+])
 
 dnl define ARCH_<NAME> conditionals
 UL_SET_ARCH([I86], [i?86-*])
index ca028baeeeab2c474f3eebb02e26f926ca20b65e..aec34394d1a27db1b6f5dd2d5f8b15b7a47ccb0c 100644 (file)
@@ -355,4 +355,12 @@ static inline int xusleep(useconds_t usec)
  */
 #define UL_GETPW_BUFSIZ        (16 * 1024)
 
+/*
+ * Darwin or other BSDs may only have MAP_ANON. To get it on Darwin we must
+ * define _DARWIN_C_SOURCE before including sys/mman.h. We do this in config.h.
+ */
+#if !defined MAP_ANONYMOUS && defined MAP_ANON
+# define MAP_ANONYMOUS  (MAP_ANON)
+#endif
+
 #endif /* UTIL_LINUX_C_H */