1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-25 12:15:32 +03:00
aports/community/kbuild/getloadavg.patch
2017-01-24 13:48:53 +00:00

32 lines
794 B
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.