Source: libaio Version: 0.3.109-3 Severity: wishlist Tags: patch User: [email protected] Usertags: arm64
Dear Maintainer, Attached is a patch which enables support for building libaio for the arm64 architecture. This mostly consists of a couple of backports from the upstream development branch. Since there is no arm64 hardware available yet this also includes support for cross compiling in a multiarch environment, essentially by simply call the triplet-qualified gcc. Thanks, Ian. -- System Information: Debian Release: 7.0 APT prefers testing APT policy: (990, 'testing'), (500, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 3.2.0-4-amd64 (SMP w/4 CPU cores) Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash
>From 74e74e6291abde1addab5547f59e226cff2c5861 Mon Sep 17 00:00:00 2001 From: Ian Campbell <[email protected]> Date: Wed, 6 Mar 2013 03:30:10 +0000 Subject: [PATCH] Support for arm64 --- debian/changelog | 8 ++ debian/patches/00_arches_arm64.patch | 157 ++++++++++++++++++++++++++++ debian/patches/00_arches_arm64_tests.patch | 46 ++++++++ debian/patches/series | 2 + debian/rules | 3 +- 5 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 debian/patches/00_arches_arm64.patch create mode 100644 debian/patches/00_arches_arm64_tests.patch diff --git a/debian/changelog b/debian/changelog index a2848db..1616279 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +libaio (0.3.109-4) UNRELEASED; urgency=low + + * Add support for arm64 architecture, backporting two patches from upstream + development branch. Also use the triplet qualified compiler in order to + allow multiarch cross building (Closes: #xxxxxx) + + -- Ian Campbell <[email protected]> Wed, 06 Mar 2013 03:27:25 +0000 + libaio (0.3.109-3) unstable; urgency=low * Escape backslash in man pages. (Closes: #651833) diff --git a/debian/patches/00_arches_arm64.patch b/debian/patches/00_arches_arm64.patch new file mode 100644 index 0000000..19f817c --- /dev/null +++ b/debian/patches/00_arches_arm64.patch @@ -0,0 +1,157 @@ +From d88423b54b84a483a36ee5c9c20397ce3102385b Mon Sep 17 00:00:00 2001 +From: Jeff Moyer <[email protected]> +Date: Wed, 30 Jan 2013 14:55:23 -0500 +Subject: [PATCH 1/2] add arm64 (aarch64) support + +The libaio.h changes came from Riku Voipio <[email protected]>. +The syscall-arm64.h file is an adapter version of the syscall-arm.h +file. + +Signed-off-by: Jeff Moyer <[email protected]> +--- + src/libaio.h | 10 +++++ + src/syscall-arm64.h | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++ + src/syscall.h | 2 + + 3 files changed, 113 insertions(+) + create mode 100644 src/syscall-arm64.h + +Index: libaio/src/libaio.h +=================================================================== +--- libaio.orig/src/libaio.h 2013-03-06 03:28:20.631977560 +0000 ++++ libaio/src/libaio.h 2013-03-06 03:28:58.163976233 +0000 +@@ -124,6 +124,16 @@ + #define PADDEDptr(x, y) x; unsigned y + #define PADDEDul(x, y) unsigned long x; unsigned y + # endif ++#elif defined(__aarch64__) ++# if defined (__AARCH64EB__) /* big endian, 64 bits */ ++#define PADDED(x, y) unsigned y; x ++#define PADDEDptr(x,y) x ++#define PADDEDul(x, y) unsigned long x ++# elif defined(__AARCH64EL__) /* little endian, 64 bits */ ++#define PADDED(x, y) x, y ++#define PADDEDptr(x, y) x ++#define PADDEDul(x, y) unsigned long x ++# endif + #else + #error endian? + #endif +Index: libaio/src/syscall-arm64.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ libaio/src/syscall-arm64.h 2013-03-06 03:28:20.631977560 +0000 +@@ -0,0 +1,101 @@ ++/* ++ * linux/include/asm-arm/unistd.h ++ * ++ * Copyright (C) 2001-2005 Russell King ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as ++ * published by the Free Software Foundation. ++ * ++ * Please forward _all_ changes to this file to [email protected], ++ * no matter what the change is. Thanks! ++ */ ++ ++#define __NR_io_setup 0 ++#define __NR_io_destroy 1 ++#define __NR_io_submit 2 ++#define __NR_io_cancel 3 ++#define __NR_io_getevents 4 ++ ++#define __sys2(x) #x ++#define __sys1(x) __sys2(x) ++ ++#define __SYS_REG(name) register long __sysreg __asm__("w8") = __NR_##name; ++#define __SYS_REG_LIST(regs...) "r" (__sysreg) , ##regs ++#define __syscall(name) "svc\t#0" ++ ++#define io_syscall1(type,fname,sname,type1,arg1) \ ++type fname(type1 arg1) { \ ++ __SYS_REG(sname) \ ++ register long __x0 __asm__("x0") = (long)arg1; \ ++ register long __res_x0 __asm__("x0"); \ ++ __asm__ __volatile__ ( \ ++ __syscall(sname) \ ++ : "=r" (__res_x0) \ ++ : __SYS_REG_LIST( "0" (__x0) ) \ ++ : "memory" ); \ ++ return (type) __res_x0; \ ++} ++ ++#define io_syscall2(type,fname,sname,type1,arg1,type2,arg2) \ ++type fname(type1 arg1,type2 arg2) { \ ++ __SYS_REG(sname) \ ++ register long __x0 __asm__("x0") = (long)arg1; \ ++ register long __x1 __asm__("x1") = (long)arg2; \ ++ register long __res_x0 __asm__("x0"); \ ++ __asm__ __volatile__ ( \ ++ __syscall(sname) \ ++ : "=r" (__res_x0) \ ++ : __SYS_REG_LIST( "0" (__x0), "r" (__x1) ) \ ++ : "memory" ); \ ++ return (type) __res_x0; \ ++} ++ ++#define io_syscall3(type,fname,sname,type1,arg1,type2,arg2,type3,arg3) \ ++type fname(type1 arg1,type2 arg2,type3 arg3) { \ ++ __SYS_REG(sname) \ ++ register long __x0 __asm__("x0") = (long)arg1; \ ++ register long __x1 __asm__("x1") = (long)arg2; \ ++ register long __x2 __asm__("x2") = (long)arg3; \ ++ register long __res_x0 __asm__("x0"); \ ++ __asm__ __volatile__ ( \ ++ __syscall(sname) \ ++ : "=r" (__res_x0) \ ++ : __SYS_REG_LIST( "0" (__x0), "r" (__x1), "r" (__x2) ) \ ++ : "memory" ); \ ++ return (type) __res_x0; \ ++} ++ ++#define io_syscall4(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\ ++type fname(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ ++ __SYS_REG(sname) \ ++ register long __x0 __asm__("x0") = (long)arg1; \ ++ register long __x1 __asm__("x1") = (long)arg2; \ ++ register long __x2 __asm__("x2") = (long)arg3; \ ++ register long __x3 __asm__("x3") = (long)arg4; \ ++ register long __res_x0 __asm__("x0"); \ ++ __asm__ __volatile__ ( \ ++ __syscall(sname) \ ++ : "=r" (__res_x0) \ ++ : __SYS_REG_LIST( "0" (__x0), "r" (__x1), "r" (__x2), "r" (__x3) ) \ ++ : "memory" ); \ ++ return (type) __res_x0; \ ++} ++ ++#define io_syscall5(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \ ++type fname(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) {\ ++ __SYS_REG(sname) \ ++ register long __x0 __asm__("x0") = (long)arg1; \ ++ register long __x1 __asm__("x1") = (long)arg2; \ ++ register long __x2 __asm__("x2") = (long)arg3; \ ++ register long __x3 __asm__("x3") = (long)arg4; \ ++ register long __x4 __asm__("x4") = (long)arg5; \ ++ register long __res_x0 __asm__("x0"); \ ++ __asm__ __volatile__ ( \ ++ __syscall(sname) \ ++ : "=r" (__res_x0) \ ++ : __SYS_REG_LIST( "0" (__x0), "r" (__x1), "r" (__x2), \ ++ "r" (__x3), "r" (__x4) ) \ ++ : "memory" ); \ ++ return (type) __res_x0; \ ++} +Index: libaio/src/syscall.h +=================================================================== +--- libaio.orig/src/syscall.h 2013-03-06 03:28:20.631977560 +0000 ++++ libaio/src/syscall.h 2013-03-06 03:29:11.003975778 +0000 +@@ -36,6 +36,8 @@ + #include "syscall-mips.h" + #elif defined(__sh__) + #include "syscall-sh.h" ++#elif defined(__aarch64__) ++#include "syscall-arm64.h" + #else + #error "add syscall-arch.h" + #endif diff --git a/debian/patches/00_arches_arm64_tests.patch b/debian/patches/00_arches_arm64_tests.patch new file mode 100644 index 0000000..679c8f3 --- /dev/null +++ b/debian/patches/00_arches_arm64_tests.patch @@ -0,0 +1,46 @@ +From b564776250eaff47728eb63c25bbefcfd1c0c240 Mon Sep 17 00:00:00 2001 +From: Jeff Moyer <[email protected]> +Date: Thu, 31 Jan 2013 15:57:02 -0500 +Subject: [PATCH 2/2] fix test case 16 to work on arm64 + +aarch64 does not implement "legacy" system calls such as eventfd. It +does, of course, support eventfd2, so use that instead. + +Reported-by: Riku Voipio <[email protected]> +Signed-off-by: Jeff Moyer <[email protected]> +--- + harness/cases/16.t | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/harness/cases/16.t b/harness/cases/16.t +index c3157cc..5a546ff 100644 +--- a/harness/cases/16.t ++++ b/harness/cases/16.t +@@ -18,6 +18,12 @@ + #define SYS_eventfd 318 + #elif defined(__alpha__) + #define SYS_eventfd 478 ++#elif defined(__aarch64__) ++/* arm64 does not implement eventfd, only eventfd2 */ ++#define USE_EVENTFD2 ++#ifndef SYS_eventfd2 ++#define SYS_eventfd2 19 ++#endif /* __aarch64__ */ + #else + #error define SYS_eventfd for your arch! + #endif +@@ -39,7 +45,11 @@ int test_main(void) + struct timespec notime = { .tv_sec = 0, .tv_nsec = 0 }; + + buf = malloc(SIZE); assert(buf); ++#ifndef USE_EVENTFD2 + efd = syscall(SYS_eventfd, 0); ++#else ++ efd = syscall(SYS_eventfd2, 0, 0); ++#endif + if (efd < 0) { + if (errno == ENOSYS) { + printf("No eventfd support. [SKIPPING]\n"); +-- +1.7.10.4 + diff --git a/debian/patches/series b/debian/patches/series index c9ed9f3..8cfaa38 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,6 +1,8 @@ 00_arches.patch 00_arches_sh.patch 00_arches_sparc64.patch +00_arches_arm64.patch +00_arches_arm64_tests.patch 01_link_libgcc.patch 02_libdevdir.patch 03_man_errors.patch diff --git a/debian/rules b/debian/rules index d842fce..1ac7be0 100755 --- a/debian/rules +++ b/debian/rules @@ -6,6 +6,7 @@ DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU) DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) +CC = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)-gcc CPPFLAGS = $(shell dpkg-buildflags --get CPPFLAGS) CFLAGS = $(shell dpkg-buildflags --get CFLAGS) -Wall LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS) @@ -20,7 +21,7 @@ build-indep: build-arch: dh_testdir - $(MAKE) CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" + $(MAKE) CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" build: build-indep build-arch -- 1.7.10.4

