summaryrefslogtreecommitdiffstats
path: root/testing/kbuild/getloadavg.patch
blob: e145ed0e5a71d7954476a530ec1c4f2334de48e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
diff --git a/src/kmk/job.c b/src/kmk/job.c
index 6d14300..16731fc 100644
--- a/src/kmk/job.c
+++ b/src/kmk/job.c
@@ -240,6 +240,27 @@ unsigned long job_counter = 0;
 
 unsigned int jobserver_tokens = 0;
 
+#ifdef __UCLIBC__
+int getloadavg(double list[], int nelem)
+{
+        FILE *LOADAVG;
+        double avg[3] = { 0.0, 0.0, 0.0 };
+        int i, res = -1;
+
+        if ((LOADAVG = fopen("/proc/loadavg", "r"))) {
+                fscanf(LOADAVG, "%lf %lf %lf", &avg[0], &avg[1], &avg[2]);
+                res = 0;
+                fclose(LOADAVG);
+        }
+
+        for (i = 0; (i < nelem) && (i < 3); i++) {
+                list[i] = avg[i];
+        }
+
+        return res;
+}
+#endif
+
 #ifdef WINDOWS32
 /*
  * The macro which references this function is defined in make.h.