mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-01-04 00:02:17 +01:00
34 lines
872 B
Diff
34 lines
872 B
Diff
--- ./gnulib/lib/physmem.c.orig
|
|
+++ ./gnulib/lib/physmem.c
|
|
@@ -23,6 +23,7 @@
|
|
#include "physmem.h"
|
|
|
|
#include <unistd.h>
|
|
+#include <stdio.h>
|
|
|
|
#if HAVE_SYS_PSTAT_H
|
|
# include <sys/pstat.h>
|
|
@@ -81,6 +82,22 @@
|
|
double
|
|
physmem_total (void)
|
|
{
|
|
+#if defined(__UCLIBC__)
|
|
+ char line[128];
|
|
+ FILE *f = fopen("/proc/meminfo", "r");
|
|
+ long double result = -1;
|
|
+ if (f == NULL)
|
|
+ return 0;
|
|
+ while (!feof(f) && fgets(line, sizeof(line)-1, f)) {
|
|
+ if (sscanf(line, "MemTotal: %Lf kB", &result) == 1) {
|
|
+ result *= 1024;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ fclose(f);
|
|
+ return result;
|
|
+#endif
|
|
+
|
|
#if defined _SC_PHYS_PAGES && defined _SC_PAGESIZE
|
|
{ /* This works on linux-gnu, solaris2 and cygwin. */
|
|
double pages = sysconf (_SC_PHYS_PAGES);
|