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.29 by root, Sat Jul 9 22:45:06 2005 UTC vs.
Revision 1.31 by root, Sun Jul 10 01:02:51 2005 UTC

284 284
285 _syscall3(long, open, char *, pathname, int, flags, int, mode) 285 _syscall3(long, open, char *, pathname, int, flags, int, mode)
286 _syscall1(long, close, unsigned int, fd) 286 _syscall1(long, close, unsigned int, fd)
287 _syscall1(long, unlink, char *, filename); 287 _syscall1(long, unlink, char *, filename);
288 _syscall1(long, fsync, unsigned int, fd); 288 _syscall1(long, fsync, unsigned int, fd);
289
290#ifndef __NR_fdatasync
291# define __NR_fdatasync __NR_fsync
292#endif
289 _syscall1(long, fdatasync, unsigned int, fd); 293 _syscall1(long, fdatasync, unsigned int, fd);
290 294
291#if BYTE_ORDER == LITTLE_ENDIAN 295#if BYTE_ORDER == LITTLE_ENDIAN
292# define LOFF_ARG(off) (off & 0xffffffff), (off >> 32) 296# define LOFF_ARG(off) (off & 0xffffffff), (off >> 32)
293#elif BYTE_ORDER == BIG_ENDIAN 297#elif BYTE_ORDER == BIG_ENDIAN
398void 402void
399max_parallel(nthreads) 403max_parallel(nthreads)
400 int nthreads 404 int nthreads
401 PROTOTYPE: $ 405 PROTOTYPE: $
402 CODE: 406 CODE:
407{
403 int cur = started; 408 int cur = started;
404 while (cur > nthreads) 409 while (cur > nthreads)
405 { 410 {
406 end_thread (); 411 end_thread ();
407 cur--; 412 cur--;
410 while (started > nthreads) 415 while (started > nthreads)
411 { 416 {
412 poll_wait (); 417 poll_wait ();
413 poll_cb (aTHX); 418 poll_cb (aTHX);
414 } 419 }
420}
415 421
416void 422void
417aio_open(pathname,flags,mode,callback) 423aio_open(pathname,flags,mode,callback)
418 SV * pathname 424 SV * pathname
419 int flags 425 int flags
420 int mode 426 int mode
421 SV * callback 427 SV * callback
422 PROTOTYPE: $$$$ 428 PROTOTYPE: $$$$
423 CODE: 429 CODE:
430{
424 aio_req req; 431 aio_req req;
425 432
426 Newz (0, req, 1, aio_cb); 433 Newz (0, req, 1, aio_cb);
427 434
428 if (!req) 435 if (!req)
434 req->fd = flags; 441 req->fd = flags;
435 req->mode = mode; 442 req->mode = mode;
436 req->callback = SvREFCNT_inc (callback); 443 req->callback = SvREFCNT_inc (callback);
437 444
438 send_req (req); 445 send_req (req);
446}
439 447
440void 448void
441aio_close(fh,callback) 449aio_close(fh,callback)
442 InputStream fh 450 InputStream fh
443 SV * callback 451 SV * callback
445 ALIAS: 453 ALIAS:
446 aio_close = REQ_CLOSE 454 aio_close = REQ_CLOSE
447 aio_fsync = REQ_FSYNC 455 aio_fsync = REQ_FSYNC
448 aio_fdatasync = REQ_FDATASYNC 456 aio_fdatasync = REQ_FDATASYNC
449 CODE: 457 CODE:
458{
450 aio_req req; 459 aio_req req;
451 460
452 Newz (0, req, 1, aio_cb); 461 Newz (0, req, 1, aio_cb);
453 462
454 if (!req) 463 if (!req)
457 req->type = ix; 466 req->type = ix;
458 req->fd = PerlIO_fileno (fh); 467 req->fd = PerlIO_fileno (fh);
459 req->callback = SvREFCNT_inc (callback); 468 req->callback = SvREFCNT_inc (callback);
460 469
461 send_req (req); 470 send_req (req);
471}
462 472
463void 473void
464aio_read(fh,offset,length,data,dataoffset,callback) 474aio_read(fh,offset,length,data,dataoffset,callback)
465 InputStream fh 475 InputStream fh
466 UV offset 476 UV offset
483 PROTOTYPE: $$$$$$ 493 PROTOTYPE: $$$$$$
484 CODE: 494 CODE:
485 read_write (aTHX_ 1, PerlIO_fileno (fh), offset, length, data, dataoffset, callback); 495 read_write (aTHX_ 1, PerlIO_fileno (fh), offset, length, data, dataoffset, callback);
486 496
487void 497void
498aio_readahead(fh,offset,length,callback)
499 InputStream fh
500 UV offset
501 IV length
502 SV * callback
503 PROTOTYPE: $$$$
504 CODE:
505{
506 aio_req req;
507
508 if (length < 0)
509 croak ("length must not be negative");
510
511 Newz (0, req, 1, aio_cb);
512
513 if (!req)
514 croak ("out of memory during aio_req allocation");
515
516 req->type = REQ_READAHEAD;
517 req->fd = PerlIO_fileno (fh);
518 req->offset = offset;
519 req->length = length;
520 req->callback = SvREFCNT_inc (callback);
521
522 send_req (req);
523}
524
525void
488aio_stat(fh_or_path,callback) 526aio_stat(fh_or_path,callback)
489 SV * fh_or_path 527 SV * fh_or_path
490 SV * callback 528 SV * callback
491 PROTOTYPE: $$ 529 PROTOTYPE: $$
492 ALIAS: 530 ALIAS:
493 aio_lstat = 1 531 aio_lstat = 1
494 CODE: 532 CODE:
533{
495 aio_req req; 534 aio_req req;
496 535
497 Newz (0, req, 1, aio_cb); 536 Newz (0, req, 1, aio_cb);
498 537
499 if (!req) 538 if (!req)
517 } 556 }
518 557
519 req->callback = SvREFCNT_inc (callback); 558 req->callback = SvREFCNT_inc (callback);
520 559
521 send_req (req); 560 send_req (req);
561}
522 562
523void 563void
524aio_unlink(pathname,callback) 564aio_unlink(pathname,callback)
525 SV * pathname 565 SV * pathname
526 SV * callback 566 SV * callback
527 PROTOTYPE: $$ 567 PROTOTYPE: $$
528 CODE: 568 CODE:
569{
529 aio_req req; 570 aio_req req;
530 571
531 Newz (0, req, 1, aio_cb); 572 Newz (0, req, 1, aio_cb);
532 573
533 if (!req) 574 if (!req)
537 req->data = newSVsv (pathname); 578 req->data = newSVsv (pathname);
538 req->dataptr = SvPV_nolen (req->data); 579 req->dataptr = SvPV_nolen (req->data);
539 req->callback = SvREFCNT_inc (callback); 580 req->callback = SvREFCNT_inc (callback);
540 581
541 send_req (req); 582 send_req (req);
583}
542 584
543int 585int
544poll_fileno() 586poll_fileno()
545 PROTOTYPE: 587 PROTOTYPE:
546 CODE: 588 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines