# --- T2-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # T2 SDE: package/.../torsmo/getloadavg.patch # Copyright (C) 2007 The T2 SDE Project # # More information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # --- T2-COPYRIGHT-NOTE-END --- --- torsmo-0.18/linux.c.vanilla 2004-12-21 21:20:07.000000000 +0000 +++ torsmo-0.18/linux.c 2007-01-14 21:05:47.000000000 +0000 @@ -243,6 +243,44 @@ update_stat(); } +/* uclibc and dietlibc do not have this junk -ReneR */ +#if defined (__UCLIBC__) || defined (__dietlibc__) +static int getloadavg (double loadavg[], int nelem) +{ + int fd; + + fd = open ("/proc/loadavg", O_RDONLY); + if (fd < 0) + return -1; + else + { + char buf[65], *p; + ssize_t nread; + int i; + + nread = read (fd, buf, sizeof buf - 1); + close (fd); + if (nread <= 0) + return -1; + buf[nread - 1] = '\0'; + + if (nelem > 3) + nelem = 3; + p = buf; + for (i = 0; i < nelem; ++i) + { + char *endp; + loadavg[i] = strtod (p, &endp); + if (endp == p) + return -1; + p = endp; + } + + return i; + } +} +#endif + void update_load_average() { #ifdef HAVE_GETLOADAVG double v[3];