[Bf-blender-cvs] [fee66f7] master: Code cleanup: defines for statfs were getting out of hand for BSD's.

Campbell Barton noreply at git.blender.org
Tue Jan 7 03:44:22 CET 2014


Commit: fee66f7bc82659143ccfe62d66c18290ffd90174
Author: Campbell Barton
Date:   Tue Jan 7 13:39:00 2014 +1100
https://developer.blender.org/rBfee66f7bc82659143ccfe62d66c18290ffd90174

Code cleanup: defines for statfs were getting out of hand for BSD's.

add __DragonFly__ and internal defines to avoid copy-pasting checks.

also remove __CYGWIN32__ check, since cygwin is no longer supported.

===================================================================

M	intern/ghost/intern/GHOST_SystemWin32.h
M	source/blender/blenlib/intern/storage.c

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index c4b8167..2aef4ba 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -44,10 +44,6 @@
 
 #include "GHOST_System.h"
 
-#if defined(__CYGWIN32__)
-#   define __int64 long long
-#endif
-
 class GHOST_EventButton;
 class GHOST_EventCursor;
 class GHOST_EventKey;
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index c0d09b2..6f03529 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -42,28 +42,26 @@
 #include <time.h>
 #include <sys/stat.h>
 
-#if defined(__sun__) || defined(__sun) || defined(__NetBSD__)
-#  include <sys/statvfs.h> /* Other modern unix os's should probably use this also */
-#elif !defined(__FreeBSD__) && !defined(__linux__) && (defined(__sparc) || defined(__sparc__))
+#if defined(__NetBSD__) || defined(__DragonFly__) || defined(__sun__) || defined(__sun)
+   /* Other modern unix os's should probably use this also */
+#  include <sys/statvfs.h>
+#  define USE_STATFS_STATVFS
+#elif (defined(__sparc) || defined(__sparc__)) && !defined(__FreeBSD__) && !defined(__linux__)
 #  include <sys/statfs.h>
+   /* 4 argument version (not common) */
+#  define USE_STATFS_4ARGS
 #endif
 
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
+   /* For statfs */
 #  include <sys/param.h>
 #  include <sys/mount.h>
 #endif
 
-#if defined(__linux__) || defined(__CYGWIN32__) || defined(__hpux) || defined(__GNU__) || defined(__GLIBC__)
-#include <sys/vfs.h>
+#if defined(__linux__) || defined(__hpux) || defined(__GNU__) || defined(__GLIBC__)
+#  include <sys/vfs.h>
 #endif
 
-#ifdef __APPLE__
-   /* For statfs */
-#  include <sys/param.h>
-#  include <sys/mount.h>
-#endif /* __APPLE__ */
-
-
 #include <fcntl.h>
 #include <string.h>  /* strcpy etc.. */
 
@@ -172,11 +170,12 @@ double BLI_dir_free_space(const char *dir)
 	return (double) (freec * bytesps * sectorspc);
 #else
 
-#if defined(__sun__) || defined(__sun) || defined(__NetBSD__)
+#ifdef USE_STATFS_STATVFS
 	struct statvfs disk;
 #else
 	struct statfs disk;
 #endif
+
 	char name[FILE_MAXDIR], *slash;
 	int len = strlen(dir);
 	
@@ -193,15 +192,12 @@ double BLI_dir_free_space(const char *dir)
 		strcpy(name, "/");
 	}
 
-#if defined(__FreeBSD__) || defined(__linux__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__GNU__) || defined(__GLIBC__)
-	if (statfs(name, &disk)) return(-1);
-#endif
-
-#if defined(__sun__) || defined(__sun) || defined(__NetBSD__)
-	if (statvfs(name, &disk)) return(-1);
-#elif !defined(__FreeBSD__) && !defined(__linux__) && (defined(__sparc) || defined(__sparc__))
-	/* WARNING - This may not be supported by geeneric unix os's - Campbell */
-	if (statfs(name, &disk, sizeof(struct statfs), 0)) return(-1);
+#if  defined(USE_STATFS_STATVFS)
+	if (statvfs(name, &disk)) return -1;
+#elif defined(USE_STATFS_4ARGS)
+	if (statfs(name, &disk, sizeof(struct statfs), 0)) return -1;
+#else
+	if (statfs(name, &disk)) return -1;
 #endif
 
 	return ( ((double) disk.f_bsize) * ((double) disk.f_bfree));




More information about the Bf-blender-cvs mailing list