[PATCH 1 of 3] setup: use a more strict way to test BSD or OSX's statfs

Jun Wu quark at fb.com
Fri Mar 24 05:32:52 UTC 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1490332536 25200
#      Thu Mar 23 22:15:36 2017 -0700
# Node ID 597a29c947fe2b9f9ac0a6a03cf710ab9f69757c
# Parent  2c02bb7fd7fc1212029dc903527e35a9efb7dbe1
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 597a29c947fe
setup: use a more strict way to test BSD or OSX's statfs

We want to use the `f_fstypename` field to get the filesystem type. Test it
directly. The new macro HAVE_BSD_STATFS implys the old HAVE_SYS_MOUNT_H and
HAVE_SYS_PARAM_H. So the latter ones are removed.

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -597,6 +597,4 @@ for plat, func in [('bsd', 'setproctitle
 
 for plat, header in [
-    ('bsd|darwin|linux', 'sys/mount.h'),
-    ('bsd|darwin|linux', 'sys/param.h'),
     ('linux', 'linux/magic.h'),
     ('linux', 'sys/vfs.h'),
@@ -606,4 +604,14 @@ for plat, header in [
         osutil_cflags.append('-DHAVE_%s' % macro)
 
+for plat, macro, code in [
+    ('bsd|darwin', 'BSD_STATFS', '''
+     #include <sys/param.h>
+     #include <sys/mount.h>
+     int main() { struct statfs s; return sizeof(s.f_fstypename); }
+     '''),
+]:
+    if re.search(plat, sys.platform) and cancompile(new_compiler(), code):
+        osutil_cflags.append('-DHAVE_%s' % macro)
+
 if sys.platform == 'darwin':
     osutil_ldflags += ['-framework', 'ApplicationServices']


More information about the Mercurial-devel mailing list