From 15e2be45860c5f7bac4beed0551ec8257e863d7e Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Sun, 12 Apr 2020 03:36:39 +0200
Subject: [PATCH libaio 08/11] Add x32 support

Signed-off-by: Guillem Jover <guillem@hadrons.org>
---
 harness/main.c       |  2 +-
 src/libaio.h         |  4 +++-
 src/syscall-x86_64.h | 10 ++++++++++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/harness/main.c b/harness/main.c
index ac0fba2..db42a18 100644
--- a/harness/main.c
+++ b/harness/main.c
@@ -14,7 +14,7 @@
 #if __LP64__ == 0
 #if defined(__i386__) || defined(__powerpc__) || defined(__mips__)
 #define KERNEL_RW_POINTER	((void *)0xc0010000)
-#elif defined(__arm__) || defined(__m68k__) || defined(__s390__) || defined(__sh__)
+#elif defined(__arm__) || defined(__m68k__) || defined(__s390__) || defined(__sh__) || defined(__x86_64__)
 #define KERNEL_RW_POINTER	((void *)0x00010000)
 #elif defined(__hppa__)
 #define KERNEL_RW_POINTER	((void *)0x10100000)
diff --git a/src/libaio.h b/src/libaio.h
index c748454..9695a53 100644
--- a/src/libaio.h
+++ b/src/libaio.h
@@ -51,7 +51,9 @@ typedef enum io_iocb_cmd {
 } io_iocb_cmd_t;
 
 /* little endian, 32 bits */
-#if defined(__i386__) || (defined(__arm__) && !defined(__ARMEB__)) || \
+#if defined(__i386__) || \
+    (defined(__x86_64__) && defined(__ILP32__)) || \
+    (defined(__arm__) && !defined(__ARMEB__)) || \
     (defined(__sh__) && defined(__LITTLE_ENDIAN__)) || \
     defined(__bfin__) || \
     (defined(__MIPSEL__) && !defined(__mips64)) || \
diff --git a/src/syscall-x86_64.h b/src/syscall-x86_64.h
index 0eccef3..6a44d53 100644
--- a/src/syscall-x86_64.h
+++ b/src/syscall-x86_64.h
@@ -1,6 +1,16 @@
+#if __ILP32__
+#define __X32_SYSCALL_BIT	0x40000000UL
+#define __NR_io_setup		(__X32_SYSCALL_BIT + 543)
+#define __NR_io_destroy		(__X32_SYSCALL_BIT + 207)
+#define __NR_io_submit		(__X32_SYSCALL_BIT + 544)
+#define __NR_io_cancel		(__X32_SYSCALL_BIT + 210)
+#define __NR_io_getevents	(__X32_SYSCALL_BIT + 208)
+#define __NR_io_pgetevents	(__X32_SYSCALL_BIT + 333)
+#else
 #define __NR_io_setup		206
 #define __NR_io_destroy		207
 #define __NR_io_getevents	208
 #define __NR_io_submit		209
 #define __NR_io_cancel		210
 #define __NR_io_pgetevents	333
+#endif
-- 
2.26.0.292.g33ef6b2f38

