mirror of
git://git.openembedded.org/meta-openembedded
synced 2026-04-02 02:49:12 +00:00
libhugetlbfs: Fix build on musl
needs more runtime testing Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
parent
1477cf5460
commit
eec73ed7c6
@ -0,0 +1,25 @@
|
||||
From d3c2187716a0a1f9359a869ca383c129603554d9 Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Thu, 21 Jun 2018 19:25:57 -0700
|
||||
Subject: [PATCH 1/6] include stddef.h for ptrdiff_t
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
morecore.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/morecore.c b/morecore.c
|
||||
index 62ad252..c5981d2 100644
|
||||
--- a/morecore.c
|
||||
+++ b/morecore.c
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
+#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
From b72bf6a81fa879f32a074fe53776fc8291c83b6f Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Thu, 21 Jun 2018 19:32:59 -0700
|
||||
Subject: [PATCH 2/6] Mark glibc specific code so
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
morecore.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/morecore.c b/morecore.c
|
||||
index c5981d2..ec9fafa 100644
|
||||
--- a/morecore.c
|
||||
+++ b/morecore.c
|
||||
@@ -347,6 +347,7 @@ void hugetlbfs_setup_morecore(void)
|
||||
|
||||
INFO("setup_morecore(): heapaddr = 0x%lx\n", heapaddr);
|
||||
|
||||
+#ifdef __GLIBC__
|
||||
heaptop = heapbase = (void *)heapaddr;
|
||||
if (__hugetlb_opts.thp_morecore)
|
||||
__morecore = &thp_morecore;
|
||||
@@ -354,7 +355,6 @@ void hugetlbfs_setup_morecore(void)
|
||||
__morecore = &hugetlbfs_morecore;
|
||||
|
||||
/* Set some allocator options more appropriate for hugepages */
|
||||
-
|
||||
if (__hugetlb_opts.shrink_ok)
|
||||
mallopt(M_TRIM_THRESHOLD, hpage_size / 2);
|
||||
else
|
||||
@@ -364,4 +364,5 @@ void hugetlbfs_setup_morecore(void)
|
||||
* This doesn't appear to prohibit malloc() from falling back
|
||||
* to mmap() if we run out of hugepages. */
|
||||
mallopt(M_MMAP_MAX, 0);
|
||||
+#endif
|
||||
}
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
From 3d6ab5ea8e23f96ee6fdd915e05acd9a751dd876 Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Thu, 21 Jun 2018 19:44:26 -0700
|
||||
Subject: [PATCH 3/6] alloc.c: Avoid sysconf(_SC_LEVEL2_CACHE_LINESIZE) on
|
||||
linux
|
||||
|
||||
musl does not have it
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
alloc.c | 15 ++++++++++++++-
|
||||
1 file changed, 14 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/alloc.c b/alloc.c
|
||||
index bce9464..cf7eb40 100644
|
||||
--- a/alloc.c
|
||||
+++ b/alloc.c
|
||||
@@ -245,6 +245,19 @@ void free_huge_pages(void *ptr)
|
||||
__free_huge_pages(ptr, 1);
|
||||
}
|
||||
|
||||
+static size_t get_cacheline_size() {
|
||||
+#if defined(__linux__)
|
||||
+ FILE * fp = fopen("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", "r");
|
||||
+ unsigned int line_size = 0;
|
||||
+ if (fp) {
|
||||
+ fscanf(fp, "%d", &line_size);
|
||||
+ fclose(fp);
|
||||
+ }
|
||||
+ return line_size;
|
||||
+#else
|
||||
+ return sysconf(_SC_LEVEL2_CACHE_LINESIZE);
|
||||
+#endif
|
||||
+}
|
||||
/*
|
||||
* Offset the buffer using bytes wasted due to alignment to avoid using the
|
||||
* same cache lines for the start of every buffer returned by
|
||||
@@ -261,7 +274,7 @@ void *cachecolor(void *buf, size_t len, size_t color_bytes)
|
||||
|
||||
/* Lookup our cacheline size once */
|
||||
if (cacheline_size == 0) {
|
||||
- cacheline_size = sysconf(_SC_LEVEL2_CACHE_LINESIZE);
|
||||
+ cacheline_size = get_cacheline_size();
|
||||
linemod = time(NULL);
|
||||
}
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
From 7002dec46dae375e8aa1aa8577a5b274c02fc697 Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Thu, 21 Jun 2018 19:48:04 -0700
|
||||
Subject: [PATCH 4/6] shm.c: Mark glibc specific changes so
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
shm.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/shm.c b/shm.c
|
||||
index 1f82cab..9447b63 100644
|
||||
--- a/shm.c
|
||||
+++ b/shm.c
|
||||
@@ -48,10 +48,11 @@
|
||||
* system shmget() may be performed without worry as there is no dynamic
|
||||
* call chain.
|
||||
*/
|
||||
+#ifdef __GLIBC__
|
||||
extern void *dlsym (void *__restrict __handle, __const char *__restrict __name)
|
||||
__attribute__((weak)) __THROW __nonnull ((2));
|
||||
extern char *dlerror (void) __attribute__((weak)) __THROW;
|
||||
-
|
||||
+#endif
|
||||
|
||||
/* call syscall shmget through the generic syscall mechanism */
|
||||
static int syscall_shmget(key_t key, size_t size, int shmflg)
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
From 87ed1706f426ed27fc4eeca7c3b09a4086c9a2a9 Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Thu, 21 Jun 2018 19:51:02 -0700
|
||||
Subject: [PATCH 5/6] Include dirent.h for ino_t
|
||||
|
||||
Fixes
|
||||
error: unknown type name 'ino_t'; did you mean 'int'?
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
tests/hugetests.h | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/tests/hugetests.h b/tests/hugetests.h
|
||||
index 8b1d8d9..056042c 100644
|
||||
--- a/tests/hugetests.h
|
||||
+++ b/tests/hugetests.h
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
+#include <dirent.h>
|
||||
|
||||
#include "libhugetlbfs_privutils.h"
|
||||
#include "libhugetlbfs_testprobes.h"
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
From 96c012ea31a2d124528f3b6f3b9857b71b059db3 Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Thu, 21 Jun 2018 19:58:53 -0700
|
||||
Subject: [PATCH 6/6] include limits.h for PATH_MAX
|
||||
|
||||
Fixes
|
||||
|
||||
error: 'PATH_MAX' undeclared
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
hugeadm.c | 1 +
|
||||
tests/gethugepagesizes.c | 1 +
|
||||
2 files changed, 2 insertions(+)
|
||||
|
||||
diff --git a/hugeadm.c b/hugeadm.c
|
||||
index fe4211d..8db274c 100644
|
||||
--- a/hugeadm.c
|
||||
+++ b/hugeadm.c
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <fcntl.h>
|
||||
+#include <limits.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
diff --git a/tests/gethugepagesizes.c b/tests/gethugepagesizes.c
|
||||
index 9551b38..2645e3f 100644
|
||||
--- a/tests/gethugepagesizes.c
|
||||
+++ b/tests/gethugepagesizes.c
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <hugetlbfs.h>
|
||||
+#include <limits.h>
|
||||
|
||||
#include "hugetests.h"
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -19,6 +19,12 @@ SRC_URI = " \
|
||||
file://0001-run_test.py-not-use-hard-coded-path-.-obj-hugeadm.patch \
|
||||
file://libhugetlbfs-elf_i386-avoid-search-host-library-path.patch \
|
||||
file://Force-text-segment-alignment-to-0x08000000-for-i386-.patch \
|
||||
file://0001-include-stddef.h-for-ptrdiff_t.patch \
|
||||
file://0002-Mark-glibc-specific-code-so.patch \
|
||||
file://0003-alloc.c-Avoid-sysconf-_SC_LEVEL2_CACHE_LINESIZE-on-l.patch \
|
||||
file://0004-shm.c-Mark-glibc-specific-changes-so.patch \
|
||||
file://0005-Include-dirent.h-for-ino_t.patch \
|
||||
file://0006-include-limits.h-for-PATH_MAX.patch \
|
||||
"
|
||||
|
||||
UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+(\.\d+)+)"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user