summaryrefslogtreecommitdiff
blob: 6ecd7f10d5ba1573f08b1f42f39d8f4ac41e51eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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