0001-getloadavg.patch 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. Fix compilation with uClibc
  2. Ported from
  3. https://github.com/stschake/buildroot-grasshopper/blob/master/package/torsmo/torsmo-0.18-uclibc-getloadavg.patch
  4. Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
  5. diff -uwNr vdr-2.3.1.org/skinlcars.c vdr-2.3.1/skinlcars.c
  6. --- vdr-2.3.1.org/skinlcars.c 2015-09-01 12:07:07.000000000 +0200
  7. +++ vdr-2.3.1/skinlcars.c 2016-07-31 21:00:11.000000000 +0200
  8. @@ -1100,6 +1100,44 @@
  9. }
  10. }
  11. +/* uclibc and dietlibc do not have this junk -ReneR */
  12. +#if defined (__UCLIBC__) || defined (__dietlibc__)
  13. +int getloadavg (double loadavg[], int nelem)
  14. +{
  15. + int fd;
  16. +
  17. + fd = open ("/proc/loadavg", O_RDONLY);
  18. + if (fd < 0)
  19. + return -1;
  20. + else
  21. + {
  22. + char buf[65], *p;
  23. + ssize_t nread;
  24. + int i;
  25. +
  26. + nread = read (fd, buf, sizeof buf - 1);
  27. + close (fd);
  28. + if (nread <= 0)
  29. + return -1;
  30. + buf[nread - 1] = '\0';
  31. +
  32. + if (nelem > 3)
  33. + nelem = 3;
  34. + p = buf;
  35. + for (i = 0; i < nelem; ++i)
  36. + {
  37. + char *endp;
  38. + loadavg[i] = strtod (p, &endp);
  39. + if (endp == p)
  40. + return -1;
  41. + p = endp;
  42. + }
  43. +
  44. + return i;
  45. + }
  46. +}
  47. +#endif
  48. +
  49. void cSkinLCARSDisplayMenu::DrawLoad(void)
  50. {
  51. if (yb04) {