From: Khem Raj <[email protected]>

newer 32bit arches e.g. RV32 and ARC do not have __NR_io_getevents
syscall and have started of with 64bit time_t so there is no 32bit
version

Signed-off-by: Khem Raj <[email protected]>
(cherry picked from commit bd8e72c1397f700fca0ddc44120abf9d325fd872)
Signed-off-by: Armin Kuster <[email protected]>
---
 meta-oe/recipes-dbs/mysql/mariadb.inc         |  2 +
 ...ck-if-syscall-exists-before-using-it.patch | 43 +++++++++++++++++++
 .../recipes-dbs/mysql/mariadb/sys_futex.patch | 22 ++++++++++
 3 files changed, 67 insertions(+)
 create mode 100644 
meta-oe/recipes-dbs/mysql/mariadb/0001-aio_linux-Check-if-syscall-exists-before-using-it.patch
 create mode 100644 meta-oe/recipes-dbs/mysql/mariadb/sys_futex.patch

diff --git a/meta-oe/recipes-dbs/mysql/mariadb.inc 
b/meta-oe/recipes-dbs/mysql/mariadb.inc
index 67cfa54f02e..9833b288571 100644
--- a/meta-oe/recipes-dbs/mysql/mariadb.inc
+++ b/meta-oe/recipes-dbs/mysql/mariadb.inc
@@ -20,6 +20,8 @@ SRC_URI = 
"https://downloads.mariadb.org/interstitial/${BP}/source/${BP}.tar.gz
            file://fix-arm-atomic.patch \
            file://0001-Fix-library-LZ4-lookup.patch \
            file://0001-innobase-Define-__NR_futex-if-it-does-not-exist.patch \
+           file://0001-aio_linux-Check-if-syscall-exists-before-using-it.patch 
\
+           file://sys_futex.patch \
           "
 SRC_URI_append_libc-musl = " file://ppc-remove-glibc-dep.patch"
 
diff --git 
a/meta-oe/recipes-dbs/mysql/mariadb/0001-aio_linux-Check-if-syscall-exists-before-using-it.patch
 
b/meta-oe/recipes-dbs/mysql/mariadb/0001-aio_linux-Check-if-syscall-exists-before-using-it.patch
new file mode 100644
index 00000000000..a2f7812c509
--- /dev/null
+++ 
b/meta-oe/recipes-dbs/mysql/mariadb/0001-aio_linux-Check-if-syscall-exists-before-using-it.patch
@@ -0,0 +1,43 @@
+From 5d9a869a72420cf0bb08b6aa93e980df90bdcf2e Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Sat, 3 Apr 2021 12:02:36 -0700
+Subject: [PATCH] aio_linux: Check if syscall exists before using it
+
+Return -ENOSYS if not implememented, fixes build on arches like RISCV32
+Fixes
+tpool/aio_linux.cc:63:20: error: '__NR_io_getevents' was not declared in this 
scope; did you mean 'io_getevents'?
+   63 |   int ret= syscall(__NR_io_getevents, reinterpret_cast<long>(ctx),
+      |                    ^~~~~~~~~~~~~~~~~
+      |                    io_getevents
+
+Upstream-Staus: Pending
+Signed-off-by: Khem Raj <[email protected]>
+---
+ tpool/aio_linux.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/tpool/aio_linux.cc b/tpool/aio_linux.cc
+index d9aa8be2..d8a87a8f 100644
+--- a/tpool/aio_linux.cc
++++ b/tpool/aio_linux.cc
+@@ -59,6 +59,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
MA 02111 - 1301 USA*/
+ */
+ static int my_getevents(io_context_t ctx, long min_nr, long nr, io_event *ev)
+ {
++#ifdef __NR_io_getevents
+   int saved_errno= errno;
+   int ret= syscall(__NR_io_getevents, reinterpret_cast<long>(ctx),
+                    min_nr, nr, ev, 0);
+@@ -68,6 +69,9 @@ static int my_getevents(io_context_t ctx, long min_nr, long 
nr, io_event *ev)
+     errno= saved_errno;
+   }
+   return ret;
++#else
++  return -ENOSYS;
++#endif
+ }
+ #endif
+ 
+-- 
+2.31.1
+
diff --git a/meta-oe/recipes-dbs/mysql/mariadb/sys_futex.patch 
b/meta-oe/recipes-dbs/mysql/mariadb/sys_futex.patch
new file mode 100644
index 00000000000..3277a3eee11
--- /dev/null
+++ b/meta-oe/recipes-dbs/mysql/mariadb/sys_futex.patch
@@ -0,0 +1,22 @@
+ Use SYS_futex for syscall
+
+glibc defines SYS_futex and on newer 32bit CPUs like RISCV-32, arc there
+is no 32bit time_t therefore define SYS_futex in terms of SYS_futex_time64
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+--- a/storage/innobase/include/ib0mutex.h
++++ b/storage/innobase/include/ib0mutex.h
+@@ -150,6 +150,12 @@ private:
+ #include <linux/futex.h>
+ #include <sys/syscall.h>
+ 
++/** Newer 32bit CPUs eg. RISCV-32 are defaulting to 64bit time_t from get go 
and
++ therefore do not define __NR_futex */
++#if !defined(SYS_futex) && defined(SYS_futex_time64)
++# define SYS_futex SYS_futex_time64
++#endif
++
+ /** Mutex implementation that used the Linux futex. */
+ template <template <typename> class Policy>
+ struct TTASFutexMutex {
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#90701): 
https://lists.openembedded.org/g/openembedded-devel/message/90701
Mute This Topic: https://lists.openembedded.org/mt/81947058/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to