port diskfree detection in fix halt for MacOSX

This commit is contained in:
Axel Kohlmeyer 2020-03-11 19:28:58 -04:00
parent 6fb42a42b8
commit ddf14763f7
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
1 changed files with 8 additions and 4 deletions

View File

@ -306,21 +306,25 @@ double FixHalt::tlimit()
/* ----------------------------------------------------------------------
determine available disk space, if supported. Return -1 if not.
------------------------------------------------------------------------- */
#if defined(__linux)
#if defined(__linux) || defined(__APPLE__)
#include <sys/statvfs.h>
#endif
double FixHalt::diskfree()
{
#if defined(__linux)
#if defined(__linux) || defined(__APPLE__)
struct statvfs fs;
double disk_free = -1.0;
if (dlimit_path) {
disk_free = 1.0e100;
int rv = statvfs(dlimit_path,&fs);
if (rv == 0)
if (rv == 0) {
#if defined(__linux)
disk_free = fs.f_bavail*fs.f_bsize/1048576.0;
else
#elif defined(__APPLE__)
disk_free = fs.f_bavail*fs.f_frsize/1048576.0;
#endif
} else
disk_free = -1.0;
MPI_Bcast(&disk_free,1,MPI_DOUBLE,0,world);