You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-libs/libaio/files/libaio-0.3.107-generic-arch...

102 lines
3.6 KiB

for arches that lack magic assembly (arm, blackfin, etc...), implement support
using standard syscall() function
--- src/libaio.h
+++ src/libaio.h
@@ -49,38 +49,34 @@ typedef enum io_iocb_cmd {
IO_CMD_PWRITEV = 8,
} io_iocb_cmd_t;
-#if defined(__i386__) /* little endian, 32 bits */
+/* little endian, 32 bits */
+#if defined(__i386__) || defined(__sh__) || defined(__bfin__) || \
+ defined(__ARMEL__) || defined(__MIPSEL__) || defined(__cris__)
#define PADDED(x, y) x; unsigned y
#define PADDEDptr(x, y) x; unsigned y
#define PADDEDul(x, y) unsigned long x; unsigned y
+
+/* little endian, 64 bits */
#elif defined(__ia64__) || defined(__x86_64__) || defined(__alpha__)
#define PADDED(x, y) x, y
#define PADDEDptr(x, y) x
#define PADDEDul(x, y) unsigned long x
-#elif defined(__powerpc64__) /* big endian, 64 bits */
+
+/* big endian, 64 bits */
+#elif defined(__powerpc64__) || defined(__s390x__) || \
+ (defined(__sparc__) && defined(__arch64__))
#define PADDED(x, y) unsigned y; x
#define PADDEDptr(x,y) x
#define PADDEDul(x, y) unsigned long x
-#elif defined(__PPC__) /* big endian, 32 bits */
+
+/* big endian, 32 bits */
+#elif defined(__PPC__) || defined(__s390__) || defined(__ARMEB__) || \
+ defined(__MIPSEB__) || defined(__sparc__) || defined(__m68k__) || \
+ defined(__hppa__) || defined(__frv__) || defined(__avr32__)
#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(__s390x__) /* 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(__s390__) /* big endian, 32 bits */
-#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(__sparc__) && defined(__arch64__) /* 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(__sparc__) /* big endian, 32 bits */
-#define PADDED(x, y) unsigned y; x
-#define PADDEDptr(x, y) unsigned y; x
-#define PADDEDul(x, y) unsigned y; unsigned long x
+
#else
#error endian?
#endif
--- /dev/null
+++ src/syscall-generic.h
@@ -0,0 +1,29 @@
+#include <errno.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#define _body_io_syscall(sname, args...) \
+{ \
+ int ret = syscall(__NR_##sname, ## args); \
+ return ret < 0 ? -errno : ret; \
+}
+
+#define io_syscall1(type,fname,sname,type1,arg1) \
+type fname(type1 arg1) \
+_body_io_syscall(sname, (long)arg1)
+
+#define io_syscall2(type,fname,sname,type1,arg1,type2,arg2) \
+type fname(type1 arg1,type2 arg2) \
+_body_io_syscall(sname, (long)arg1, (long)arg2)
+
+#define io_syscall3(type,fname,sname,type1,arg1,type2,arg2,type3,arg3) \
+type fname(type1 arg1,type2 arg2,type3 arg3) \
+_body_io_syscall(sname, (long)arg1, (long)arg2, (long)arg3)
+
+#define io_syscall4(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type fname (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+_body_io_syscall(sname, (long)arg1, (long)arg2, (long)arg3, (long)arg4)
+
+#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) \
+_body_io_syscall(sname, (long)arg1, (long)arg2, (long)arg3, (long)arg4, (long)arg5)
--- src/syscall.h
+++ src/syscall.h
@@ -25,5 +25,6 @@
#elif defined(__sparc__)
#include "syscall-sparc.h"
#else
-#error "add syscall-arch.h"
+#warning "using generic syscall method"
+#include "syscall-generic.h"
#endif