Lines 42-47
Link Here
|
42 |
#include <sys/stat.h> |
42 |
#include <sys/stat.h> |
43 |
#include <termios.h> |
43 |
#include <termios.h> |
44 |
|
44 |
|
|
|
45 |
#ifdef __FreeBSD__ |
46 |
#include <sys/vmmeter.h> |
47 |
#endif |
48 |
|
45 |
|
49 |
|
46 |
#ifdef HAVE_SENDFILE |
50 |
#ifdef HAVE_SENDFILE |
47 |
#ifdef HAVE_SENDFILE_H |
51 |
#ifdef HAVE_SENDFILE_H |
Lines 956-964
Link Here
|
956 |
debugmsg("total # of phys pages: %li\n",NumP); |
960 |
debugmsg("total # of phys pages: %li\n",NumP); |
957 |
} |
961 |
} |
958 |
#elif defined(__FreeBSD__) |
962 |
#elif defined(__FreeBSD__) |
959 |
size_t nump_size = sizeof(nump_size); |
963 |
/* Get free memory average */ |
960 |
sysctlbyname("hw.availpages", &NumP, &nump_size, NULL, 0); |
964 |
struct vmtotal vmt; |
|
|
965 |
size_t vmt_size = sizeof(vmt); |
966 |
if (sysctlbyname("vm.vmtotal", &vmt, &vmt_size, NULL, 0) < 0) |
967 |
fatal("Unable to read vm.vmtotal"); |
968 |
if (vmt_size != sizeof(vmt)) |
969 |
fatal("Unable to read (wrong size) vm.vmtotal"); |
970 |
NumP = vmt.t_free; |
961 |
#endif |
971 |
#endif |
|
|
972 |
long mxnrsem = sysconf(_SC_SEM_VALUE_MAX); |
962 |
|
973 |
|
963 |
#ifdef _SC_PAGESIZE |
974 |
#ifdef _SC_PAGESIZE |
964 |
PgSz = sysconf(_SC_PAGESIZE); |
975 |
PgSz = sysconf(_SC_PAGESIZE); |
Lines 972-977
Link Here
|
972 |
Blocksize = PgSz; |
983 |
Blocksize = PgSz; |
973 |
debugmsg("Blocksize set to physical page size of %u bytes\n",PgSz); |
984 |
debugmsg("Blocksize set to physical page size of %u bytes\n",PgSz); |
974 |
Numblocks = NumP/50; |
985 |
Numblocks = NumP/50; |
|
|
986 |
if (mxnrsem < Numblocks) |
987 |
Numblocks = mxnrsem; |
975 |
debugmsg("set Numblocks to %u\n",Numblocks); |
988 |
debugmsg("set Numblocks to %u\n",Numblocks); |
976 |
} |
989 |
} |
977 |
|
990 |
|