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.186 by root, Thu Jul 14 22:36:17 2011 UTC vs.
Revision 1.187 by root, Sat Jul 16 16:46:10 2011 UTC

22#endif 22#endif
23 23
24/* perl namespace pollution */ 24/* perl namespace pollution */
25#undef VERSION 25#undef VERSION
26 26
27/* perl stupidly overrides readdir and maybe others */
28/* with thread-unsafe versions, imagine that :( */
29#undef readdir
30#undef opendir
31#undef closedir
32
27#ifdef _WIN32 33#ifdef _WIN32
28 34
29# define EIO_STRUCT_DIRENT Direntry_t 35# define EIO_STRUCT_DIRENT Direntry_t
30# undef malloc 36# undef malloc
31# undef free 37# undef free
34# undef open 40# undef open
35# undef read 41# undef read
36# undef write 42# undef write
37# undef send 43# undef send
38# undef recv 44# undef recv
39# undef stat 45# undef lstat
40# undef fstat
41# define lstat stat
42# undef truncate 46# undef truncate
43# undef ftruncate 47# undef ftruncate
44# undef open 48# undef open
49# undef link
45# undef close 50# undef close
46# undef unlink 51# undef unlink
52# undef mkdir
47# undef rmdir 53# undef rmdir
48# undef rename 54# undef rename
49# undef lseek 55# undef lseek
56# undef opendir
57# undef readdir
58# undef closedir
59# undef chmod
60# undef fchmod
50 61
51# define opendir(fd) (errno = ENOSYS, 0) 62# define opendir(fd) EIO_ERRNO (ENOSYS, 0)
52# define readdir(fd) (errno = ENOSYS, -1) 63# define readdir(fd) EIO_ENOSYS ()
53# define closedir(fd) (errno = ENOSYS, -1) 64# define closedir(fd) EIO_ENOSYS ()
54 65
55#else 66#else
56 67
57# include <sys/time.h> 68# include <sys/time.h>
58# include <sys/select.h> 69# include <sys/select.h>
59# include <unistd.h> 70# include <unistd.h>
60# include <utime.h> 71# include <utime.h>
61# include <signal.h> 72# include <signal.h>
62# define EIO_STRUCT_DIRENT struct dirent
63 73
64#endif 74#endif
65
66/* perl stupidly overrides readdir and maybe others */
67/* with thread-unsafe versions, imagine that :( */
68#undef readdir
69#undef opendir
70#undef closedir
71 75
72#define EIO_STRUCT_STAT Stat_t 76#define EIO_STRUCT_STAT Stat_t
73 77
74/* use NV for 32 bit perls as it allows larger offsets */ 78/* use NV for 32 bit perls as it allows larger offsets */
75#if IVSIZE >= 8 79#if IVSIZE >= 8
212#endif 216#endif
213#ifndef PROT_EXEC 217#ifndef PROT_EXEC
214# define PROT_EXEC 0 218# define PROT_EXEC 0
215#endif 219#endif
216 220
221#ifndef ST_RDONLY
222# define ST_RDONLY 0
223#endif
224#ifndef ST_NOSUID
225# define ST_NOSUID 0
226#endif
217#ifndef ST_NODEV 227#ifndef ST_NODEV
218# define ST_NODEV 0 228# define ST_NODEV 0
219#endif 229#endif
220#ifndef ST_NOEXEC 230#ifndef ST_NOEXEC
221# define ST_NOEXEC 0 231# define ST_NOEXEC 0
530 case EIO_STATVFS: 540 case EIO_STATVFS:
531 case EIO_FSTATVFS: 541 case EIO_FSTATVFS:
532 { 542 {
533 SV *rv = &PL_sv_undef; 543 SV *rv = &PL_sv_undef;
534 544
545#ifndef _WIN32
535 if (req->result >= 0) 546 if (req->result >= 0)
536 { 547 {
537 EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); 548 EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req);
538 HV *hv = newHV (); 549 HV *hv = newHV ();
539 550
549 hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); 560 hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0);
550 hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); 561 hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0);
551 hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); 562 hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0);
552 hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); 563 hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0);
553 } 564 }
565#endif
554 566
555 PUSHs (rv); 567 PUSHs (rv);
556 } 568 }
557 569
558 break; 570 break;
1028 1040
1029void 1041void
1030aio_close (SV *fh, SV *callback=&PL_sv_undef) 1042aio_close (SV *fh, SV *callback=&PL_sv_undef)
1031 PPCODE: 1043 PPCODE:
1032{ 1044{
1033 static int close_pipe = -1; /* dummy fd to close fds via dup2 */ 1045 static int close_fd = -1; /* dummy fd to close fds via dup2 */
1034 int fd = s_fileno_croak (fh, 0); 1046 int fd = s_fileno_croak (fh, 0);
1035 dREQ; 1047 dREQ;
1036 1048
1037 if (close_pipe < 0) 1049 if (expect_false (close_fd < 0))
1038 { 1050 {
1051#ifdef _WIN32
1052 close_fd = _open_osfhandle (socket (AF_INET, SOCK_STREAM, 0), 0);
1053#else
1039 int pipefd [2]; 1054 int pipefd [2];
1040 1055
1041 if (pipe (pipefd) < 0 1056 if (pipe (pipefd) < 0
1042 || close (pipefd [1]) < 0 1057 || close (pipefd [1]) < 0
1043 || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0) 1058 || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0)
1044 abort (); /*D*/ 1059 abort (); /*D*/
1045 1060
1046 close_pipe = pipefd [0]; 1061 close_fd = pipefd [0];
1062#endif
1047 } 1063 }
1048 1064
1049 req->type = EIO_DUP2; 1065 req->type = EIO_DUP2;
1050 req->int1 = close_pipe; 1066 req->int1 = close_fd;
1051 req->sv2 = newSVsv (fh); 1067 req->sv2 = newSVsv (fh);
1052 req->int2 = fd; 1068 req->int2 = fd;
1053 1069
1054 REQ_SEND (req); 1070 REQ_SEND (req);
1055} 1071}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines