blob: 8d71ecbc0f487975edd957dfe68895a2261a2dbc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
From 83944758dc0703afea81f3c7aa0ad926bc5df757 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 14 Dec 2015 00:47:53 +0000
Subject: [PATCH 08/16] util: bypass unimplemented _SC_PHYS_PAGES system
configuration API on uclibc
Upstream-Status: Inappropriate [uclibc-specific]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/basic/util.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/basic/util.c b/src/basic/util.c
index 9e0b576..65f0edf 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -769,10 +769,25 @@ uint64_t physical_memory(void) {
/* We return this as uint64_t in case we are running as 32bit
* process on a 64bit kernel with huge amounts of memory */
+#ifdef __UCLIBC__
+ char line[128];
+ FILE *f = fopen("/proc/meminfo", "r");
+ if (f == NULL)
+ return 0;
+ while (!feof(f) && fgets(line, sizeof(line)-1, f)) {
+ if (sscanf(line, "MemTotal: %li kB", &mem) == 1) {
+ mem *= 1024;
+ break;
+ }
+ }
+ fclose(f);
+ return (uint64_t) mem;
+#else
mem = sysconf(_SC_PHYS_PAGES);
assert(mem > 0);
return (uint64_t) mem * (uint64_t) page_size();
+#endif
}
int update_reboot_param_file(const char *param) {
--
2.6.4
|