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