Line 0
Link Here
|
|
|
1 |
--- dynare++/kord/journal.cweb.orig 2013-11-08 16:37:59 UTC |
2 |
+++ dynare++/kord/journal.cweb |
3 |
@@ -5,6 +5,8 @@ |
4 |
@c |
5 |
#include "journal.h" |
6 |
#include "kord_exception.h" |
7 |
+#include <sys/types.h> |
8 |
+#include <sys/sysctl.h> |
9 |
|
10 |
#if !defined(__MINGW32__) |
11 |
# include <sys/resource.h> |
12 |
@@ -72,7 +74,16 @@ long int SystemResources::onlineProcesso |
13 |
@<|SystemResources::availableMemory| code@>= |
14 |
long int SystemResources::availableMemory() |
15 |
{ |
16 |
- return pageSize()*sysconf(_SC_AVPHYS_PAGES); |
17 |
+ long value; |
18 |
+ size_t len; |
19 |
+ char *path = "vm.stats.vm.v_free_count"; |
20 |
+ |
21 |
+ if (sysctlbyname(path, &value, &len, NULL, 0) == -1) { |
22 |
+ return (-1); |
23 |
+ } |
24 |
+ |
25 |
+ |
26 |
+ return pageSize() * value; |
27 |
} |
28 |
|
29 |
@ Here we read the current values of resource usage. For MinGW, we |
30 |
@@ -84,6 +95,10 @@ void SystemResources::getRUS(double& loa |
31 |
long int& idrss, long int& majflt) |
32 |
{ |
33 |
struct timeval now; |
34 |
+ long value; |
35 |
+ size_t len; |
36 |
+ char *path = "vm.stats.vm.v_free_count"; |
37 |
+ |
38 |
gettimeofday(&now, NULL); |
39 |
elapsed = now.tv_sec-start.tv_sec + (now.tv_usec-start.tv_usec)*1.0e-6; |
40 |
|
41 |
@@ -107,7 +122,11 @@ void SystemResources::getRUS(double& loa |
42 |
load_avg = -1.0; |
43 |
#endif |
44 |
|
45 |
- pg_avail = sysconf(_SC_AVPHYS_PAGES); |
46 |
+ if (sysctlbyname(path, &value, &len, NULL, 0) == -1) { |
47 |
+ pg_avail = -1; |
48 |
+ } |
49 |
+ |
50 |
+ pg_avail = value; |
51 |
} |
52 |
|
53 |
@ |