ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev_linuxaio.c
(Generate patch)

Comparing libev/ev_linuxaio.c (file contents):
Revision 1.42 by root, Mon Jul 1 20:47:38 2019 UTC vs.
Revision 1.43 by root, Mon Jul 1 21:47:42 2019 UTC

116 unsigned header_length; /* size of aio_ring */ 116 unsigned header_length; /* size of aio_ring */
117 117
118 struct io_event io_events[0]; 118 struct io_event io_events[0];
119}; 119};
120 120
121/*
122 * define some syscall wrappers for common architectures
123 * this is mostly for nice looks during debugging, not performance.
124 * our syscalls return < 0, not == -1, on error. which is good
125 * enough for linux aio.
126 * TODO: arm is also common nowadays, maybe even mips and x86
127 * TODO: after implementing this, it suddenly looks like overkill, but its hard to remove...
128 */
129#if __GNUC__ && __linux && ECB_AMD64 && !defined __OPTIMIZE_SIZE__
130 /* the costly errno access probably kills this for size optimisation */
131
132 #define ev_syscall(nr,narg,arg1,arg2,arg3,arg4,arg5) \
133 ({ \
134 long res; \
135 register unsigned long r5 __asm__ ("r8" ); \
136 register unsigned long r4 __asm__ ("r10"); \
137 register unsigned long r3 __asm__ ("rdx"); \
138 register unsigned long r2 __asm__ ("rsi"); \
139 register unsigned long r1 __asm__ ("rdi"); \
140 if (narg >= 5) r5 = (unsigned long)(arg5); \
141 if (narg >= 4) r4 = (unsigned long)(arg4); \
142 if (narg >= 3) r3 = (unsigned long)(arg3); \
143 if (narg >= 2) r2 = (unsigned long)(arg2); \
144 if (narg >= 1) r1 = (unsigned long)(arg1); \
145 __asm__ __volatile__ ( \
146 "syscall\n\t" \
147 : "=a" (res) \
148 : "0" (nr), "r" (r1), "r" (r2), "r" (r3), "r" (r4), "r" (r5) \
149 : "cc", "r11", "cx", "memory"); \
150 errno = -res; \
151 res; \
152 })
153
154#endif
155
156#ifdef ev_syscall
157 #define ev_syscall0(nr) ev_syscall (nr, 0, 0, 0, 0, 0, 0
158 #define ev_syscall1(nr,arg1) ev_syscall (nr, 1, arg1, 0, 0, 0, 0)
159 #define ev_syscall2(nr,arg1,arg2) ev_syscall (nr, 2, arg1, arg2, 0, 0, 0)
160 #define ev_syscall3(nr,arg1,arg2,arg3) ev_syscall (nr, 3, arg1, arg2, arg3, 0, 0)
161 #define ev_syscall4(nr,arg1,arg2,arg3,arg4) ev_syscall (nr, 3, arg1, arg2, arg3, arg4, 0)
162 #define ev_syscall5(nr,arg1,arg2,arg3,arg4,arg5) ev_syscall (nr, 5, arg1, arg2, arg3, arg4, arg5)
163#else
164 #define ev_syscall0(nr) syscall (nr)
165 #define ev_syscall1(nr,arg1) syscall (nr, arg1)
166 #define ev_syscall2(nr,arg1,arg2) syscall (nr, arg1, arg2)
167 #define ev_syscall3(nr,arg1,arg2,arg3) syscall (nr, arg1, arg2, arg3)
168 #define ev_syscall4(nr,arg1,arg2,arg3,arg4) syscall (nr, arg1, arg2, arg3, arg4)
169 #define ev_syscall5(nr,arg1,arg2,arg3,arg4,arg5) syscall (nr, arg1, arg2, arg3, arg4, arg5)
170#endif
171
172inline_size 121inline_size
173int 122int
174evsys_io_setup (unsigned nr_events, aio_context_t *ctx_idp) 123evsys_io_setup (unsigned nr_events, aio_context_t *ctx_idp)
175{ 124{
176 return ev_syscall2 (SYS_io_setup, nr_events, ctx_idp); 125 return ev_syscall2 (SYS_io_setup, nr_events, ctx_idp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines