From 07b82aa58c776e0607fa469d87e7bf8dbb8780b4 Mon Sep 17 00:00:00 2001
From: Jitesh Shah <jiteshs@marvell.com>
Date: Mon, 1 Jun 2009 12:19:36 +0200
Subject: [PATCH] Include support for ARM

Signed-off-by: Jitesh Shah <jiteshs@marvell.com>
---
 libaio-arm-syscall.patch |  304 ++++++++++++++++++++++++++++++++++++++++++++++
 libaio.spec              |    7 +-
 2 files changed, 310 insertions(+), 1 deletions(-)
 create mode 100644 libaio-arm-syscall.patch

diff --git a/libaio-arm-syscall.patch b/libaio-arm-syscall.patch
new file mode 100644
index 0000000..2d6fd14
--- /dev/null
+++ b/libaio-arm-syscall.patch
@@ -0,0 +1,304 @@
+diff -durN libaio-0.3.107.backup/compat-libaio-0.3.107/src/libaio.h libaio-0.3.107/compat-libaio-0.3.107/src/libaio.h
+--- libaio-0.3.107.backup/compat-libaio-0.3.107/src/libaio.h	2009-06-01 12:25:46.176556620 +0200
++++ libaio-0.3.107/compat-libaio-0.3.107/src/libaio.h	2009-06-02 07:06:01.156552705 +0200
+@@ -81,6 +81,16 @@
+ #define PADDED(x, y)    unsigned y; x
+ #define PADDEDptr(x, y) unsigned y; x
+ #define PADDEDul(x, y)  unsigned y; unsigned long x
++#elif defined(__arm__) 
++#   if defined(__ARMEB__)
++#define PADDED(x, y)    unsigned y; x
++#define PADDEDptr(x,y)  x
++#define PADDEDul(x, y)  unsigned long x
++#   else
++#define PADDED(x, y)    x; unsigned y
++#define PADDEDptr(x, y) x; unsigned y
++#define PADDEDul(x, y)  unsigned long x; unsigned y
++#   endif
+ #else
+ #error	endian?
+ #endif
+diff -durN libaio-0.3.107.backup/compat-libaio-0.3.107/src/syscall-arm.h libaio-0.3.107/compat-libaio-0.3.107/src/syscall-arm.h
+--- libaio-0.3.107.backup/compat-libaio-0.3.107/src/syscall-arm.h	1970-01-01 01:00:00.000000000 +0100
++++ libaio-0.3.107/compat-libaio-0.3.107/src/syscall-arm.h	2009-06-02 07:06:01.156552705 +0200
+@@ -0,0 +1,116 @@
++/*
++ *  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 rmk@arm.linux.org.uk,
++ * no matter what the change is.  Thanks!
++ */
++
++#define __NR_OABI_SYSCALL_BASE	0x900000
++
++#if defined(__thumb__) || defined(__ARM_EABI__)
++#define __NR_SYSCALL_BASE	0
++#else
++#define __NR_SYSCALL_BASE	__NR_OABI_SYSCALL_BASE
++#endif
++
++#define __NR_io_setup			(__NR_SYSCALL_BASE+243)
++#define __NR_io_destroy			(__NR_SYSCALL_BASE+244)
++#define __NR_io_getevents		(__NR_SYSCALL_BASE+245)
++#define __NR_io_submit			(__NR_SYSCALL_BASE+246)
++#define __NR_io_cancel			(__NR_SYSCALL_BASE+247)
++
++#define __sys2(x) #x
++#define __sys1(x) __sys2(x)
++
++#if defined(__thumb__) || defined(__ARM_EABI__)
++#define __SYS_REG(name) register long __sysreg __asm__("r7") = __NR_##name;
++#define __SYS_REG_LIST(regs...) "r" (__sysreg) , ##regs
++#define __syscall(name) "swi\t0"
++#else
++#define __SYS_REG(name)
++#define __SYS_REG_LIST(regs...) regs
++#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
++#endif
++
++#define io_syscall1(type,fname,sname,type1,arg1)			\
++type fname(type1 arg1) {						\
++  __SYS_REG(sname)							\
++  register long __r0 __asm__("r0") = (long)arg1;			\
++  register long __res_r0 __asm__("r0");					\
++  __asm__ __volatile__ (						\
++  __syscall(sname)							\
++	: "=r" (__res_r0)						\
++	: __SYS_REG_LIST( "0" (__r0) )					\
++	: "memory" );							\
++  return (type) __res_r0;						\
++}
++
++#define io_syscall2(type,fname,sname,type1,arg1,type2,arg2)		\
++type fname(type1 arg1,type2 arg2) {					\
++  __SYS_REG(sname)							\
++  register long __r0 __asm__("r0") = (long)arg1;			\
++  register long __r1 __asm__("r1") = (long)arg2;			\
++  register long __res_r0 __asm__("r0");					\
++  __asm__ __volatile__ (						\
++  __syscall(sname)							\
++	: "=r" (__res_r0)						\
++	: __SYS_REG_LIST( "0" (__r0), "r" (__r1) )			\
++	: "memory" );							\
++  return (type) __res_r0;						\
++}
++
++#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 __r0 __asm__("r0") = (long)arg1;			\
++  register long __r1 __asm__("r1") = (long)arg2;			\
++  register long __r2 __asm__("r2") = (long)arg3;			\
++  register long __res_r0 __asm__("r0");					\
++  __asm__ __volatile__ (						\
++  __syscall(sname)							\
++	: "=r" (__res_r0)						\
++	: __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2) )		\
++	: "memory" );							\
++  return (type) __res_r0;						\
++}
++
++#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 __r0 __asm__("r0") = (long)arg1;			\
++  register long __r1 __asm__("r1") = (long)arg2;			\
++  register long __r2 __asm__("r2") = (long)arg3;			\
++  register long __r3 __asm__("r3") = (long)arg4;			\
++  register long __res_r0 __asm__("r0");					\
++  __asm__ __volatile__ (						\
++  __syscall(sname)							\
++	: "=r" (__res_r0)						\
++	: __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) ) \
++	: "memory" );							\
++  return (type) __res_r0;						\
++}
++
++#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 __r0 __asm__("r0") = (long)arg1;			\
++  register long __r1 __asm__("r1") = (long)arg2;			\
++  register long __r2 __asm__("r2") = (long)arg3;			\
++  register long __r3 __asm__("r3") = (long)arg4;			\
++  register long __r4 __asm__("r4") = (long)arg5;			\
++  register long __res_r0 __asm__("r0");					\
++  __asm__ __volatile__ (						\
++  __syscall(sname)							\
++	: "=r" (__res_r0)						\
++	: __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2),		\
++			  "r" (__r3), "r" (__r4) )			\
++	: "memory" );							\
++  return (type) __res_r0;						\
++}
++
+diff -durN libaio-0.3.107.backup/compat-libaio-0.3.107/src/syscall.h libaio-0.3.107/compat-libaio-0.3.107/src/syscall.h
+--- libaio-0.3.107.backup/compat-libaio-0.3.107/src/syscall.h	2009-06-01 12:25:46.176556620 +0200
++++ libaio-0.3.107/compat-libaio-0.3.107/src/syscall.h	2009-06-02 07:06:01.156552705 +0200
+@@ -24,6 +24,8 @@
+ #include "syscall-alpha.h"
+ #elif defined(__sparc__)
+ #include "syscall-sparc.h"
++#elif defined(__arm__)
++#include "syscall-arm.h"
+ #else
+ #error "add syscall-arch.h"
+ #endif
+diff -durN libaio-0.3.107.backup/src/libaio.h libaio-0.3.107/src/libaio.h
+--- libaio-0.3.107.backup/src/libaio.h	2009-06-01 12:25:46.166557261 +0200
++++ libaio-0.3.107/src/libaio.h	2009-06-01 12:30:42.777865041 +0200
+@@ -81,6 +81,16 @@
+ #define PADDED(x, y)    unsigned y; x
+ #define PADDEDptr(x, y) unsigned y; x
+ #define PADDEDul(x, y)  unsigned y; unsigned long x
++#elif defined(__arm__) 
++#   if defined(__ARMEB__)
++#define PADDED(x, y)    unsigned y; x
++#define PADDEDptr(x,y)  x
++#define PADDEDul(x, y)  unsigned long x
++#   else
++#define PADDED(x, y)    x; unsigned y
++#define PADDEDptr(x, y) x; unsigned y
++#define PADDEDul(x, y)  unsigned long x; unsigned y
++#   endif
+ #else
+ #error	endian?
+ #endif
+diff -durN libaio-0.3.107.backup/src/syscall-arm.h libaio-0.3.107/src/syscall-arm.h
+--- libaio-0.3.107.backup/src/syscall-arm.h	1970-01-01 01:00:00.000000000 +0100
++++ libaio-0.3.107/src/syscall-arm.h	2009-06-01 12:26:06.546555325 +0200
+@@ -0,0 +1,116 @@
++/*
++ *  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 rmk@arm.linux.org.uk,
++ * no matter what the change is.  Thanks!
++ */
++
++#define __NR_OABI_SYSCALL_BASE	0x900000
++
++#if defined(__thumb__) || defined(__ARM_EABI__)
++#define __NR_SYSCALL_BASE	0
++#else
++#define __NR_SYSCALL_BASE	__NR_OABI_SYSCALL_BASE
++#endif
++
++#define __NR_io_setup			(__NR_SYSCALL_BASE+243)
++#define __NR_io_destroy			(__NR_SYSCALL_BASE+244)
++#define __NR_io_getevents		(__NR_SYSCALL_BASE+245)
++#define __NR_io_submit			(__NR_SYSCALL_BASE+246)
++#define __NR_io_cancel			(__NR_SYSCALL_BASE+247)
++
++#define __sys2(x) #x
++#define __sys1(x) __sys2(x)
++
++#if defined(__thumb__) || defined(__ARM_EABI__)
++#define __SYS_REG(name) register long __sysreg __asm__("r7") = __NR_##name;
++#define __SYS_REG_LIST(regs...) "r" (__sysreg) , ##regs
++#define __syscall(name) "swi\t0"
++#else
++#define __SYS_REG(name)
++#define __SYS_REG_LIST(regs...) regs
++#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
++#endif
++
++#define io_syscall1(type,fname,sname,type1,arg1)			\
++type fname(type1 arg1) {						\
++  __SYS_REG(sname)							\
++  register long __r0 __asm__("r0") = (long)arg1;			\
++  register long __res_r0 __asm__("r0");					\
++  __asm__ __volatile__ (						\
++  __syscall(sname)							\
++	: "=r" (__res_r0)						\
++	: __SYS_REG_LIST( "0" (__r0) )					\
++	: "memory" );							\
++  return (type) __res_r0;						\
++}
++
++#define io_syscall2(type,fname,sname,type1,arg1,type2,arg2)		\
++type fname(type1 arg1,type2 arg2) {					\
++  __SYS_REG(sname)							\
++  register long __r0 __asm__("r0") = (long)arg1;			\
++  register long __r1 __asm__("r1") = (long)arg2;			\
++  register long __res_r0 __asm__("r0");					\
++  __asm__ __volatile__ (						\
++  __syscall(sname)							\
++	: "=r" (__res_r0)						\
++	: __SYS_REG_LIST( "0" (__r0), "r" (__r1) )			\
++	: "memory" );							\
++  return (type) __res_r0;						\
++}
++
++#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 __r0 __asm__("r0") = (long)arg1;			\
++  register long __r1 __asm__("r1") = (long)arg2;			\
++  register long __r2 __asm__("r2") = (long)arg3;			\
++  register long __res_r0 __asm__("r0");					\
++  __asm__ __volatile__ (						\
++  __syscall(sname)							\
++	: "=r" (__res_r0)						\
++	: __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2) )		\
++	: "memory" );							\
++  return (type) __res_r0;						\
++}
++
++#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 __r0 __asm__("r0") = (long)arg1;			\
++  register long __r1 __asm__("r1") = (long)arg2;			\
++  register long __r2 __asm__("r2") = (long)arg3;			\
++  register long __r3 __asm__("r3") = (long)arg4;			\
++  register long __res_r0 __asm__("r0");					\
++  __asm__ __volatile__ (						\
++  __syscall(sname)							\
++	: "=r" (__res_r0)						\
++	: __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) ) \
++	: "memory" );							\
++  return (type) __res_r0;						\
++}
++
++#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 __r0 __asm__("r0") = (long)arg1;			\
++  register long __r1 __asm__("r1") = (long)arg2;			\
++  register long __r2 __asm__("r2") = (long)arg3;			\
++  register long __r3 __asm__("r3") = (long)arg4;			\
++  register long __r4 __asm__("r4") = (long)arg5;			\
++  register long __res_r0 __asm__("r0");					\
++  __asm__ __volatile__ (						\
++  __syscall(sname)							\
++	: "=r" (__res_r0)						\
++	: __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2),		\
++			  "r" (__r3), "r" (__r4) )			\
++	: "memory" );							\
++  return (type) __res_r0;						\
++}
++
+diff -durN libaio-0.3.107.backup/src/syscall.h libaio-0.3.107/src/syscall.h
+--- libaio-0.3.107.backup/src/syscall.h	2009-06-01 12:25:46.166557261 +0200
++++ libaio-0.3.107/src/syscall.h	2009-06-01 12:27:33.136554424 +0200
+@@ -24,6 +24,8 @@
+ #include "syscall-alpha.h"
+ #elif defined(__sparc__)
+ #include "syscall-sparc.h"
++#elif defined(__arm__)
++#include "syscall-arm.h"
+ #else
+ #error "add syscall-arch.h"
+ #endif
diff --git a/libaio.spec b/libaio.spec
index 8bff875..1f75144 100644
--- a/libaio.spec
+++ b/libaio.spec
@@ -1,6 +1,6 @@
 Name: libaio
 Version: 0.3.107
-Release: 8%{?dist}
+Release: 8%{?dist}.fa1
 Summary: Linux-native asynchronous I/O access library
 License: LGPLv2+
 Group:  System Environment/Libraries
@@ -8,6 +8,7 @@ Source: %{name}-%{version}.tar.gz
 BuildRoot: %{_tmppath}/%{name}-root
 Patch1: libaio-install-to-slash.patch
 Patch2: libaio-sparc.patch
+Patch3: libaio-arm-syscall.patch
 
 %description
 The Linux-native asynchronous I/O facility ("async I/O", or "aio") has a
@@ -34,6 +35,7 @@ for the Linux-native asynchronous I/O facility ("async I/O", or "aio").
 %patch1 -p1
 mv %{name}-%{version} compat-%{name}-%{version}
 %patch2 -p1
+%patch3 -p1
 
 %build
 # A library with a soname of 1.0.0 was inadvertantly released.  This
@@ -73,6 +75,9 @@ make destdir=$RPM_BUILD_ROOT prefix=/ libdir=%{libdir} usrlibdir=%{usrlibdir} \
 %attr(0644,root,root) %{_libdir}/libaio.a
 
 %changelog
+* Mon Jun 1 2009 Kedar Sovani <kedars@marvell.com> - 0.3.107-8.fa1
+- Include support for arm architectures. Patch picked from Debian
+
 * Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3.107-8
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
 
-- 
1.5.5.6

