ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-AIO/AIO.xs
(Generate patch)

Comparing Linux-AIO/AIO.xs (file contents):
Revision 1.25 by root, Thu Jul 7 22:24:09 2005 UTC vs.
Revision 1.27 by root, Fri Jul 8 03:10:00 2005 UTC

8#include <sys/stat.h> 8#include <sys/stat.h>
9#include <unistd.h> 9#include <unistd.h>
10#include <fcntl.h> 10#include <fcntl.h>
11#include <signal.h> 11#include <signal.h>
12#include <sched.h> 12#include <sched.h>
13#include <endian.h>
13 14
14typedef void *InputStream; /* hack, but 5.6.1 is simply toooo old ;) */ 15typedef void *InputStream; /* hack, but 5.6.1 is simply toooo old ;) */
15typedef void *OutputStream; /* hack, but 5.6.1 is simply toooo old ;) */ 16typedef void *OutputStream; /* hack, but 5.6.1 is simply toooo old ;) */
16typedef void *InOutStream; /* hack, but 5.6.1 is simply toooo old ;) */ 17typedef void *InOutStream; /* hack, but 5.6.1 is simply toooo old ;) */
17 18
18// 128 seems to be enough most everywhere. alpha needs 256. 19#if __i386 || __amd64
19#define STACKSIZE (256 * sizeof (long)) 20# define STACKSIZE ( 256 * sizeof (long))
21#elif __ia64
22# define STACKSIZE (8192 * sizeof (long))
23#else
24# define STACKSIZE ( 512 * sizeof (long))
25#endif
20 26
21enum { 27enum {
22 REQ_QUIT, 28 REQ_QUIT,
23 REQ_OPEN, REQ_CLOSE, REQ_READ, REQ_WRITE, 29 REQ_OPEN, REQ_CLOSE, REQ_READ, REQ_WRITE,
24 REQ_STAT, REQ_LSTAT, REQ_FSTAT, REQ_UNLINK 30 REQ_STAT, REQ_LSTAT, REQ_FSTAT, REQ_UNLINK
63 aio_thread *thr; 69 aio_thread *thr;
64 70
65 New (0, thr, 1, aio_thread); 71 New (0, thr, 1, aio_thread);
66 72
67 if (clone (aio_proc, 73 if (clone (aio_proc,
68 &(thr->stack[STACKSIZE - sizeof (long)]), 74 &(thr->stack[STACKSIZE - 16]),
69 CLONE_VM|CLONE_FS|CLONE_FILES, 75 CLONE_VM|CLONE_FS|CLONE_FILES,
70 thr) >= 0) 76 thr) >= 0)
71 started++; 77 started++;
72 else 78 else
73 Safefree (thr); 79 Safefree (thr);
233 239
234#undef errno 240#undef errno
235#include <asm/unistd.h> 241#include <asm/unistd.h>
236#include <sys/prctl.h> 242#include <sys/prctl.h>
237 243
244#if BYTE_ORDER == LITTLE_ENDIAN
245# define LONG_LONG_PAIR(HI, LO) LO, HI
246#elif BYTE_ORDER == BIG_ENDIAN
247# define LONG_LONG_PAIR(HI, LO) HI, LO
248#endif
249
238#if __alpha || __ia64 || __hppa || __sparc64__ || __v850__ 250#if __alpha || __ia64 || __hppa || __v850__
239# define stat kernelstat 251# define stat kernelstat
240# define stat64 kernelstat64 252# define stat64 kernelstat64
241# include <asm/stat.h> 253# include <asm/stat.h>
242# undef stat 254# undef stat
243# undef stat64 255# undef stat64
275 287
276 _syscall3(int,open,char *,pathname,int,flags,mode_t,mode) 288 _syscall3(int,open,char *,pathname,int,flags,mode_t,mode)
277 _syscall1(int,close,int,fd) 289 _syscall1(int,close,int,fd)
278 290
279#if __NR_pread64 291#if __NR_pread64
280 _syscall5(int,pread64,int,fd,char *,buf,size_t,count,unsigned int,offset_lo,unsigned int,offset_hi) 292 _syscall5(int,pread64,int,fd,char *,buf,size_t,count,unsigned int,offset_lh,unsigned int,offset_hl)
281 _syscall5(int,pwrite64,int,fd,char *,buf,size_t,count,unsigned int,offset_lo,unsigned int,offset_hi) 293 _syscall5(int,pwrite64,int,fd,char *,buf,size_t,count,unsigned int,offset_lh,unsigned int,offset_hl)
282#elif __NR_pread 294#elif __NR_pread
283 _syscall4(int,pread,int,fd,char *,buf,size_t,count,offset_t,offset) 295 _syscall4(int,pread,int,fd,char *,buf,size_t,count,offset_t,offset)
284 _syscall4(int,pwrite,int,fd,char *,buf,size_t,count,offset_t,offset) 296 _syscall4(int,pwrite,int,fd,char *,buf,size_t,count,offset_t,offset)
285#else 297#else
286# error "neither pread nor pread64 defined" 298# error "neither pread nor pread64 defined"
311 errno = 0; /* strictly unnecessary */ 323 errno = 0; /* strictly unnecessary */
312 324
313 switch (req->type) 325 switch (req->type)
314 { 326 {
315#if __NR_pread64 327#if __NR_pread64
316 case REQ_READ: req->result = pread64 (req->fd, req->dataptr, req->length, req->offset & 0xffffffff, req->offset >> 32); break; 328 case REQ_READ: req->result = pread64 (req->fd, req->dataptr, req->length,
329 LONG_LONG_PAIR (req->offset >> 32, req->offset & 0xffffffff)); break;
317 case REQ_WRITE: req->result = pwrite64(req->fd, req->dataptr, req->length, req->offset & 0xffffffff, req->offset >> 32); break; 330 case REQ_WRITE: req->result = pwrite64(req->fd, req->dataptr, req->length,
331 LONG_LONG_PAIR (req->offset >> 32, req->offset & 0xffffffff)); break;
318#else 332#else
319 case REQ_READ: req->result = pread (req->fd, req->dataptr, req->length, req->offset); break; 333 case REQ_READ: req->result = pread (req->fd, req->dataptr, req->length, req->offset); break;
320 case REQ_WRITE: req->result = pwrite (req->fd, req->dataptr, req->length, req->offset); break; 334 case REQ_WRITE: req->result = pwrite (req->fd, req->dataptr, req->length, req->offset); break;
321#endif 335#endif
322#if __NR_stat64 336#if __NR_stat64

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines