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

Comparing IO-AIO/AIO.xs (file contents):
Revision 1.181 by root, Tue Feb 15 03:21:41 2011 UTC vs.
Revision 1.185 by root, Thu Jul 7 22:36:18 2011 UTC

121#define EIO_NO_WRAPPERS 1 121#define EIO_NO_WRAPPERS 1
122 122
123#include "libeio/config.h" 123#include "libeio/config.h"
124#include "libeio/eio.h" 124#include "libeio/eio.h"
125 125
126/* Linux/others */
127#ifndef O_ASYNC
128# define O_ASYNC 0
129#endif
130#ifndef O_DIRECT
131# define O_DIRECT 0
132#endif
133#ifndef O_NOATIME
134# define O_NOATIME 0
135#endif
136
137/* POSIX */
138#ifndef O_CLOEXEC
139# define O_CLOEXEC 0
140#endif
141#ifndef O_NOFOLLOW
142# define O_NOFOLLOW 0
143#endif
144#ifndef O_NOCTTY
145# define O_NOCTTY 0
146#endif
147#ifndef O_NONBLOCK
148# define O_NONBLOCK 0
149#endif
150#ifndef O_EXEC
151# define O_EXEC 0
152#endif
153#ifndef O_SEARCH
154# define O_SEARCH 0
155#endif
156#ifndef O_DIRECTORY
157# define O_DIRECTORY 0
158#endif
159#ifndef O_DSYNC
160# define O_DSYNC 0
161#endif
162#ifndef O_RSYNC
163# define O_RSYNC 0
164#endif
165#ifndef O_SYNC
166# define O_SYNC 0
167#endif
168#ifndef O_TTY_INIT
169# define O_TTY_INIT 0
170#endif
171
126#ifndef POSIX_FADV_NORMAL 172#ifndef POSIX_FADV_NORMAL
127# define POSIX_FADV_NORMAL 0 173# define POSIX_FADV_NORMAL 0
128#endif 174#endif
129#ifndef POSIX_FADV_SEQUENTIAL 175#ifndef POSIX_FADV_SEQUENTIAL
130# define POSIX_FADV_SEQUENTIAL 0 176# define POSIX_FADV_SEQUENTIAL 0
539 case EIO_NOP: 585 case EIO_NOP:
540 case EIO_BUSY: 586 case EIO_BUSY:
541 break; 587 break;
542 588
543 case EIO_READLINK: 589 case EIO_READLINK:
590 case EIO_REALPATH:
544 if (req->result > 0) 591 if (req->result > 0)
545 PUSHs (sv_2mortal (newSVpvn (req->ptr2, req->result))); 592 PUSHs (sv_2mortal (newSVpvn (req->ptr2, req->result)));
546 break; 593 break;
547 594
548 case EIO_STAT: 595 case EIO_STAT:
620 grp->sv2 = 0; 667 grp->sv2 = 0;
621 668
622 eio_grp_cancel (grp); 669 eio_grp_cancel (grp);
623} 670}
624 671
625static void
626create_respipe (void) 672static void create_respipe (void)
627{ 673{
628 if (s_epipe_renew (&respipe)) 674 if (s_epipe_renew (&respipe))
629 croak ("IO::AIO: unable to initialize result pipe"); 675 croak ("IO::AIO: unable to initialize result pipe");
630} 676}
631 677
685# define MAP_FIXED 0 731# define MAP_FIXED 0
686#endif 732#endif
687 733
688#define MMAP_MAGIC PERL_MAGIC_ext 734#define MMAP_MAGIC PERL_MAGIC_ext
689 735
690static int
691mmap_free (pTHX_ SV *sv, MAGIC *mg) 736static int mmap_free (pTHX_ SV *sv, MAGIC *mg)
692{ 737{
693 int old_errno = errno; 738 int old_errno = errno;
694 munmap (mg->mg_ptr, (size_t)mg->mg_obj); 739 munmap (mg->mg_ptr, (size_t)mg->mg_obj);
695 errno = old_errno; 740 errno = old_errno;
696 741
712 0, 0, 0, 0, mmap_free 757 0, 0, 0, 0, mmap_free
713}; 758};
714 759
715/*****************************************************************************/ 760/*****************************************************************************/
716 761
717static SV *
718get_cb (SV *cb_sv) 762static SV * get_cb (SV *cb_sv)
719{ 763{
720 SvGETMAGIC (cb_sv); 764 SvGETMAGIC (cb_sv);
721 return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; 765 return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0;
722} 766}
723 767
765 const_iv (O_CREAT) 809 const_iv (O_CREAT)
766 const_iv (O_TRUNC) 810 const_iv (O_TRUNC)
767 const_iv (O_EXCL) 811 const_iv (O_EXCL)
768 const_iv (O_APPEND) 812 const_iv (O_APPEND)
769 813
814 const_iv (O_ASYNC)
815 const_iv (O_DIRECT)
816 const_iv (O_NOATIME)
817
818 const_iv (O_CLOEXEC)
819 const_iv (O_NOCTTY)
820 const_iv (O_NOFOLLOW)
821 const_iv (O_NONBLOCK)
822 const_iv (O_EXEC)
823 const_iv (O_SEARCH)
824 const_iv (O_DIRECTORY)
825 const_iv (O_DSYNC)
826 const_iv (O_RSYNC)
827 const_iv (O_SYNC)
828 const_iv (O_TTY_INIT)
829
770 const_iv (S_IFIFO) 830 const_iv (S_IFIFO)
771 const_iv (S_IFCHR) 831 const_iv (S_IFCHR)
772 const_iv (S_IFBLK) 832 const_iv (S_IFBLK)
773 const_iv (S_IFLNK) 833 const_iv (S_IFLNK)
774 const_iv (S_IFREG) 834 const_iv (S_IFREG)
831 891
832 const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) 892 const_eio (SYNC_FILE_RANGE_WAIT_BEFORE)
833 const_eio (SYNC_FILE_RANGE_WRITE) 893 const_eio (SYNC_FILE_RANGE_WRITE)
834 const_eio (SYNC_FILE_RANGE_WAIT_AFTER) 894 const_eio (SYNC_FILE_RANGE_WAIT_AFTER)
835 895
896 const_eio (FALLOC_FL_KEEP_SIZE)
897
836 const_eio (READDIR_DENTS) 898 const_eio (READDIR_DENTS)
837 const_eio (READDIR_DIRS_FIRST) 899 const_eio (READDIR_DIRS_FIRST)
838 const_eio (READDIR_STAT_ORDER) 900 const_eio (READDIR_STAT_ORDER)
839 const_eio (READDIR_FOUND_UNKNOWN) 901 const_eio (READDIR_FOUND_UNKNOWN)
840 902
952 req->sv1 = newSVsv (fh); 1014 req->sv1 = newSVsv (fh);
953 req->int1 = fd; 1015 req->int1 = fd;
954 req->offs = offset; 1016 req->offs = offset;
955 req->size = nbytes; 1017 req->size = nbytes;
956 req->int2 = flags; 1018 req->int2 = flags;
1019
1020 REQ_SEND (req);
1021}
1022
1023void
1024aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef)
1025 PPCODE:
1026{
1027 int fd = s_fileno_croak (fh, 0);
1028 dREQ;
1029
1030 req->type = EIO_FALLOCATE;
1031 req->sv1 = newSVsv (fh);
1032 req->int1 = fd;
1033 req->int2 = mode;
1034 req->offs = offset;
1035 req->size = len;
957 1036
958 REQ_SEND (req); 1037 REQ_SEND (req);
959} 1038}
960 1039
961void 1040void
1039 } 1118 }
1040} 1119}
1041 1120
1042void 1121void
1043aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) 1122aio_readlink (SV8 *path, SV *callback=&PL_sv_undef)
1123 ALIAS:
1124 aio_readlink = EIO_READLINK
1125 aio_realpath = EIO_REALPATH
1044 PPCODE: 1126 PPCODE:
1045{ 1127{
1046 SV *data; 1128 SV *data;
1047 dREQ; 1129 dREQ;
1048 1130
1049 req->type = EIO_READLINK; 1131 req->type = ix;
1050 req->sv1 = newSVsv (path); 1132 req->sv1 = newSVsv (path);
1051 req->ptr1 = SvPVbyte_nolen (req->sv1); 1133 req->ptr1 = SvPVbyte_nolen (req->sv1);
1052 1134
1053 REQ_SEND; 1135 REQ_SEND;
1054} 1136}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines