From 0a3222338efc108c831fbdd719a47d35f4b0adcd Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 18 Aug 2021 06:49:25 +0000
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 <raj.khem@gmail.com>
---
 tpool/aio_linux.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tpool/aio_linux.cc b/tpool/aio_linux.cc
index 4abc213..da75411 100644
--- a/tpool/aio_linux.cc
+++ b/tpool/aio_linux.cc
@@ -58,6 +58,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);
@@ -67,6 +68,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
 }
 
 
-- 
2.29.2

