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.9 by root, Thu Aug 16 18:58:34 2001 UTC vs.
Revision 1.10 by root, Thu Aug 30 03:11:06 2001 UTC

8#include <signal.h> 8#include <signal.h>
9#include <sched.h> 9#include <sched.h>
10 10
11#define STACKSIZE 1024 /* yeah */ 11#define STACKSIZE 1024 /* yeah */
12 12
13enum { REQ_QUIT, REQ_READ, REQ_WRITE, REQ_OPEN }; 13enum { REQ_QUIT, REQ_READ, REQ_WRITE, REQ_OPEN, REQ_CLOSE };
14 14
15typedef struct { 15typedef struct {
16 char stack[STACKSIZE]; 16 char stack[STACKSIZE];
17} aio_thread; 17} aio_thread;
18 18
177 /* we rely on gcc's ability to create closures. */ 177 /* we rely on gcc's ability to create closures. */
178 _syscall3(int,lseek,int,fd,off_t,offset,int,whence); 178 _syscall3(int,lseek,int,fd,off_t,offset,int,whence);
179 _syscall3(int,read,int,fd,char *,buf,off_t,count); 179 _syscall3(int,read,int,fd,char *,buf,off_t,count);
180 _syscall3(int,write,int,fd,char *,buf,off_t,count); 180 _syscall3(int,write,int,fd,char *,buf,off_t,count);
181 _syscall3(int,open,char *,pathname,int,flags,mode_t,mode); 181 _syscall3(int,open,char *,pathname,int,flags,mode_t,mode);
182 _syscall1(int,close,int,fd);
182 183
183 /* then loop */ 184 /* then loop */
184 while (read (reqpipe[0], (void *)&req, sizeof (req)) == sizeof (req)) 185 while (read (reqpipe[0], (void *)&req, sizeof (req)) == sizeof (req))
185 { 186 {
186 req->thread = thr; 187 req->thread = thr;
197 } 198 }
198 } 199 }
199 else if (req->type == REQ_OPEN) 200 else if (req->type == REQ_OPEN)
200 { 201 {
201 req->result = open (req->dataptr, req->fd, req->mode); 202 req->result = open (req->dataptr, req->fd, req->mode);
203 }
204 else if (req->type == REQ_CLOSE)
205 {
206 req->result = close (req->fd);
202 } 207 }
203 else 208 else
204 { 209 {
205 write (respipe[1], (void *)&req, sizeof (req)); 210 write (respipe[1], (void *)&req, sizeof (req));
206 break; 211 break;
294 req->mode = mode; 299 req->mode = mode;
295 req->callback = SvREFCNT_inc (callback); 300 req->callback = SvREFCNT_inc (callback);
296 301
297 send_req (req); 302 send_req (req);
298 303
304void
305aio_close(fh,callback)
306 PerlIO * fh
307 SV * callback
308 PROTOTYPE: $
309 CODE:
310 aio_req req;
311
312 New (0, req, 1, aio_cb);
313
314 if (!req)
315 croak ("out of memory during aio_req allocation");
316
317 req->type = REQ_CLOSE;
318 req->fd = PerlIO_fileno (fh);
319 req->callback = SvREFCNT_inc (callback);
320
321 send_req (req);
322
299int 323int
300poll_fileno() 324poll_fileno()
301 PROTOTYPE: 325 PROTOTYPE:
302 CODE: 326 CODE:
303 RETVAL = respipe[0]; 327 RETVAL = respipe[0];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines