]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
io: Make mremap conditional
authorJan Tulak <jtulak@redhat.com>
Tue, 13 Oct 2015 23:58:24 +0000 (10:58 +1100)
committerDave Chinner <david@fromorbit.com>
Tue, 13 Oct 2015 23:58:24 +0000 (10:58 +1100)
Don't build mremap on platforms where it has no support.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
configure.ac
include/builddefs.in
include/darwin.h
io/Makefile
io/mmap.c
m4/package_libcdev.m4

index 5d8486e64913fbfbca756115b19d9fc333c8baf5..7cb87bcc442aa6315d3cd9a58cc0002033a97c2b 100644 (file)
@@ -124,6 +124,7 @@ AC_HAVE_MNTENT
 AC_HAVE_FLS
 AC_HAVE_READDIR
 AC_HAVE_FSETXATTR
+AC_HAVE_MREMAP
 
 if test "$enable_blkid" = yes; then
 AC_HAVE_BLKID_TOPO
index 31e21baba58385b776107942cd16041c17ccf53b..c1797fd2e26a75554651c6a1c16b313a987578e4 100644 (file)
@@ -107,6 +107,7 @@ HAVE_READDIR = @have_readdir@
 HAVE_MNTENT = @have_mntent@
 HAVE_FLS = @have_fls@
 HAVE_FSETXATTR = @have_fsetxattr@
+HAVE_MREMAP = @have_mremap@
 
 GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall 
 #         -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
index 288ad1fb8e48ee277237af45dc550c15e1c3d662..8b769d9feca4c790778831ebcb3deba485ff1abd 100644 (file)
@@ -33,6 +33,7 @@
 #include <mach/mach_time.h>
 #include <inttypes.h>
 #include <stdio.h>
+#include <sys/mman.h>
 
 #include <machine/endian.h>
 #define __BYTE_ORDER   BYTE_ORDER
index 6c4810e2581c061a41a8a64b341ca1775ac70c70..a5f2ac929a22224f89b3b17808816d38b7f21da0 100644 (file)
@@ -90,6 +90,10 @@ CFILES += readdir.c
 LCFLAGS += -DHAVE_READDIR
 endif
 
+ifeq ($(HAVE_MREMAP),yes)
+LCFLAGS += -DHAVE_MREMAP
+endif
+
 default: depend $(LTCOMMAND)
 
 include $(BUILDRULES)
index f26276e520f619d7f5b2a6bff56642cb67a6491b..7093650ace9f86c80567075e911b7b025deef4ac 100644 (file)
--- a/io/mmap.c
+++ b/io/mmap.c
@@ -28,7 +28,9 @@ static cmdinfo_t mread_cmd;
 static cmdinfo_t msync_cmd;
 static cmdinfo_t munmap_cmd;
 static cmdinfo_t mwrite_cmd;
+#ifdef HAVE_MREMAP
 static cmdinfo_t mremap_cmd;
+#endif /* HAVE_MREMAP */
 
 mmap_region_t  *maptable;
 int            mapcount;
@@ -574,6 +576,7 @@ mwrite_f(
        return 0;
 }
 
+#ifdef HAVE_MREMAP
 static void
 mremap_help(void)
 {
@@ -633,6 +636,7 @@ mremap_f(
 
        return 0;
 }
+#endif /* HAVE_MREMAP */
 
 void
 mmap_init(void)
@@ -688,6 +692,7 @@ mmap_init(void)
                _("writes data into a region in the current memory mapping");
        mwrite_cmd.help = mwrite_help;
 
+#ifdef HAVE_MREMAP
        mremap_cmd.name = "mremap";
        mremap_cmd.altname = "mrm";
        mremap_cmd.cfunc = mremap_f;
@@ -698,11 +703,14 @@ mmap_init(void)
        mremap_cmd.oneline =
                _("alters the size of the current memory mapping");
        mremap_cmd.help = mremap_help;
+#endif /* HAVE_MREMAP */
 
        add_command(&mmap_cmd);
        add_command(&mread_cmd);
        add_command(&msync_cmd);
        add_command(&munmap_cmd);
        add_command(&mwrite_cmd);
+#ifdef HAVE_MREMAP
        add_command(&mremap_cmd);
+#endif /* HAVE_MREMAP */
 }
index 5e900abe62d13c81ea2144e7a09710f9bfd91e86..b6a7a5457c78e5863b702effb75be3bf9401d970 100644 (file)
@@ -235,3 +235,16 @@ AC_DEFUN([AC_HAVE_MNTENT],
     have_mntent=yes)
     AC_SUBST(have_mntent)
   ])
+
+#
+# Check if we have a mremap call (not on Mac OS X)
+#
+AC_DEFUN([AC_HAVE_MREMAP],
+  [ AC_CHECK_DECL([mremap],
+       have_mremap=yes,
+       [],
+       [#define _GNU_SOURCE
+        #include <sys/mman.h>]
+       )
+    AC_SUBST(have_mremap)
+  ])