Dash:
[t2.git] / package / x11 / torsmo / getloadavg.patch
blob739521df40c7b46bdca6e1ac4b01104e276af912
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/.../torsmo/getloadavg.patch
5 # Copyright (C) 2007 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 # --- T2-COPYRIGHT-NOTE-END ---
17 --- torsmo-0.18/linux.c.vanilla 2004-12-21 21:20:07.000000000 +0000
18 +++ torsmo-0.18/linux.c 2007-01-14 21:05:47.000000000 +0000
19 @@ -243,6 +243,44 @@
20 update_stat();
23 +/* uclibc and dietlibc do not have this junk -ReneR */
24 +#if defined (__UCLIBC__) || defined (__dietlibc__)
25 +static int getloadavg (double loadavg[], int nelem)
27 + int fd;
29 + fd = open ("/proc/loadavg", O_RDONLY);
30 + if (fd < 0)
31 + return -1;
32 + else
33 + {
34 + char buf[65], *p;
35 + ssize_t nread;
36 + int i;
38 + nread = read (fd, buf, sizeof buf - 1);
39 + close (fd);
40 + if (nread <= 0)
41 + return -1;
42 + buf[nread - 1] = '\0';
44 + if (nelem > 3)
45 + nelem = 3;
46 + p = buf;
47 + for (i = 0; i < nelem; ++i)
48 + {
49 + char *endp;
50 + loadavg[i] = strtod (p, &endp);
51 + if (endp == p)
52 + return -1;
53 + p = endp;
54 + }
56 + return i;
57 + }
59 +#endif
61 void update_load_average() {
62 #ifdef HAVE_GETLOADAVG
63 double v[3];