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.175 by root, Wed Dec 1 04:43:12 2010 UTC vs.
Revision 1.181 by root, Tue Feb 15 03:21:41 2011 UTC

16#include <sys/statvfs.h> 16#include <sys/statvfs.h>
17#include <limits.h> 17#include <limits.h>
18#include <fcntl.h> 18#include <fcntl.h>
19#include <sched.h> 19#include <sched.h>
20 20
21#if _POSIX_MEMLOCK || _POSIX_MAPPED_FILES 21#if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES
22# include <sys/mman.h> 22# include <sys/mman.h>
23#endif 23#endif
24 24
25/* perl namespace pollution */ 25/* perl namespace pollution */
26#undef VERSION 26#undef VERSION
118 STRLEN stroffset; \ 118 STRLEN stroffset; \
119 SV *self; 119 SV *self;
120 120
121#define EIO_NO_WRAPPERS 1 121#define EIO_NO_WRAPPERS 1
122 122
123#include "libeio/config.h"
123#include "libeio/eio.h" 124#include "libeio/eio.h"
124 125
125#ifndef POSIX_FADV_NORMAL 126#ifndef POSIX_FADV_NORMAL
126# define POSIX_FADV_NORMAL 0 127# define POSIX_FADV_NORMAL 0
127#endif 128#endif
205#ifndef ST_NODIRATIME 206#ifndef ST_NODIRATIME
206# define ST_NODIRATIME 0 207# define ST_NODIRATIME 0
207#endif 208#endif
208#ifndef ST_RELATIME 209#ifndef ST_RELATIME
209# define ST_RELATIME 0 210# define ST_RELATIME 0
211#endif
212
213#ifndef S_IFIFO
214# define S_IFIFO 0
215#endif
216#ifndef S_IFCHR
217# define S_IFCHR 0
218#endif
219#ifndef S_IFBLK
220# define S_IFBLK 0
221#endif
222#ifndef S_IFLNK
223# define S_IFLNK 0
224#endif
225#ifndef S_IFREG
226# define S_IFREG 0
227#endif
228#ifndef S_IFDIR
229# define S_IFDIR 0
230#endif
231#ifndef S_IFWHT
232# define S_IFWHT 0
233#endif
234#ifndef S_IFSOCK
235# define S_IFSOCK 0
210#endif 236#endif
211 237
212#ifndef MAP_ANONYMOUS 238#ifndef MAP_ANONYMOUS
213# ifdef MAP_ANON 239# ifdef MAP_ANON
214# define MAP_ANONYMOUS MAP_ANON 240# define MAP_ANONYMOUS MAP_ANON
228#ifndef MAP_POPULATE 254#ifndef MAP_POPULATE
229# define MAP_POPULATE 0 255# define MAP_POPULATE 0
230#endif 256#endif
231#ifndef MAP_NONBLOCK 257#ifndef MAP_NONBLOCK
232# define MAP_NONBLOCK 0 258# define MAP_NONBLOCK 0
259#endif
260
261#ifndef makedev
262# define makedev(maj,min) (((maj) << 8) | (min))
263#endif
264#ifndef major
265# define major(dev) ((dev) >> 8)
266#endif
267#ifndef minor
268# define minor(dev) ((dev) & 0xff)
233#endif 269#endif
234 270
235#ifndef PAGESIZE 271#ifndef PAGESIZE
236# define PAGESIZE sysconf (_SC_PAGESIZE) 272# define PAGESIZE sysconf (_SC_PAGESIZE)
237#endif 273#endif
352 /* do not recreate the result IV from scratch each time */ 388 /* do not recreate the result IV from scratch each time */
353 if (expect_true (sv_result_cache)) 389 if (expect_true (sv_result_cache))
354 { 390 {
355 sv_result = sv_result_cache; sv_result_cache = 0; 391 sv_result = sv_result_cache; sv_result_cache = 0;
356 SvIV_set (sv_result, req->result); 392 SvIV_set (sv_result, req->result);
393 SvIOK_only (sv_result);
357 } 394 }
358 else 395 else
359 { 396 {
360 sv_result = newSViv (req->result); 397 sv_result = newSViv (req->result);
361 SvREADONLY_on (sv_result); 398 SvREADONLY_on (sv_result);
525 SvSETMAGIC (req->sv2); 562 SvSETMAGIC (req->sv2);
526 PUSHs (sv_result); 563 PUSHs (sv_result);
527 } 564 }
528 break; 565 break;
529 566
530 case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), su fudge result value */ 567 case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), so fudge result value */
531 if (req->result > 0) 568 if (req->result > 0)
532 SvIV_set (sv_result, 0); 569 SvIV_set (sv_result, 0);
533 /* FALLTHROUGH */ 570 /* FALLTHROUGH */
534 571
535 default: 572 default:
635/*****************************************************************************/ 672/*****************************************************************************/
636 673
637#if !_POSIX_MAPPED_FILES 674#if !_POSIX_MAPPED_FILES
638# define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) 675# define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1)
639# define munmap(addr,length) (errno = ENOSYS, -1) 676# define munmap(addr,length) (errno = ENOSYS, -1)
677#endif
678
679#if !_POSIX_MEMORY_PROTECTION
640# define mprotect(addr,len,prot) (errno = ENOSYS, -1) 680# define mprotect(addr,len,prot) (errno = ENOSYS, -1)
641# define PROT_NONE 0 681# define PROT_NONE 0
642# define PROT_WRITE 0 682# define PROT_WRITE 0
643# define MAP_PRIVATE 0 683# define MAP_PRIVATE 0
644# define MAP_SHARED 0 684# define MAP_SHARED 0
724 const_iv (O_RDWR) 764 const_iv (O_RDWR)
725 const_iv (O_CREAT) 765 const_iv (O_CREAT)
726 const_iv (O_TRUNC) 766 const_iv (O_TRUNC)
727 const_iv (O_EXCL) 767 const_iv (O_EXCL)
728 const_iv (O_APPEND) 768 const_iv (O_APPEND)
729#ifndef _WIN32 769
730 const_iv (S_IFIFO) 770 const_iv (S_IFIFO)
731#endif 771 const_iv (S_IFCHR)
772 const_iv (S_IFBLK)
773 const_iv (S_IFLNK)
774 const_iv (S_IFREG)
775 const_iv (S_IFDIR)
776 const_iv (S_IFWHT)
777 const_iv (S_IFSOCK)
778 const_iv (S_IFMT)
779
732 const_niv (FADV_NORMAL , POSIX_FADV_NORMAL) 780 const_niv (FADV_NORMAL , POSIX_FADV_NORMAL)
733 const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL) 781 const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL)
734 const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) 782 const_niv (FADV_RANDOM , POSIX_FADV_RANDOM)
735 const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) 783 const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE)
736 const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) 784 const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED)
818 /* atfork child called in fifo order, so before eio's handler */ 866 /* atfork child called in fifo order, so before eio's handler */
819 X_THREAD_ATFORK (0, 0, atfork_child); 867 X_THREAD_ATFORK (0, 0, atfork_child);
820} 868}
821 869
822void 870void
823max_poll_reqs (int nreqs) 871max_poll_reqs (unsigned int nreqs)
824 PROTOTYPE: $ 872 PROTOTYPE: $
825 CODE: 873 CODE:
826 eio_set_max_poll_reqs (nreqs); 874 eio_set_max_poll_reqs (nreqs);
827 875
828void 876void
830 PROTOTYPE: $ 878 PROTOTYPE: $
831 CODE: 879 CODE:
832 eio_set_max_poll_time (nseconds); 880 eio_set_max_poll_time (nseconds);
833 881
834void 882void
835min_parallel (int nthreads) 883min_parallel (unsigned int nthreads)
836 PROTOTYPE: $ 884 PROTOTYPE: $
837 CODE: 885 CODE:
838 eio_set_min_parallel (nthreads); 886 eio_set_min_parallel (nthreads);
839 887
840void 888void
841max_parallel (int nthreads) 889max_parallel (unsigned int nthreads)
842 PROTOTYPE: $ 890 PROTOTYPE: $
843 CODE: 891 CODE:
844 eio_set_max_parallel (nthreads); 892 eio_set_max_parallel (nthreads);
845 893
846void 894void
847max_idle (int nthreads) 895max_idle (unsigned int nthreads)
848 PROTOTYPE: $ 896 PROTOTYPE: $
849 CODE: 897 CODE:
850 eio_set_max_idle (nthreads); 898 eio_set_max_idle (nthreads);
851 899
852void 900void
901idle_timeout (unsigned int seconds)
902 PROTOTYPE: $
903 CODE:
904 eio_set_idle_timeout (seconds);
905
906void
853max_outstanding (int maxreqs) 907max_outstanding (unsigned int maxreqs)
854 PROTOTYPE: $ 908 PROTOTYPE: $
855 CODE: 909 CODE:
856 max_outstanding = maxreqs; 910 max_outstanding = maxreqs;
857 911
858void 912void
1058 } 1112 }
1059 1113
1060 REQ_SEND; 1114 REQ_SEND;
1061} 1115}
1062 1116
1117UV
1118major (UV dev)
1119 ALIAS:
1120 minor = 1
1121 CODE:
1122 RETVAL = ix ? major (dev) : minor (dev);
1123 OUTPUT:
1124 RETVAL
1125
1126UV
1127makedev (UV maj, UV min)
1128 CODE:
1129 RETVAL = makedev (maj, min);
1130 OUTPUT:
1131 RETVAL
1132
1063void 1133void
1064aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) 1134aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef)
1065 PPCODE: 1135 PPCODE:
1066{ 1136{
1067 dREQ; 1137 dREQ;
1522 if (!SvOK (length) || len + offset > svlen) 1592 if (!SvOK (length) || len + offset > svlen)
1523 len = svlen - offset; 1593 len = svlen - offset;
1524 1594
1525 addr = (void *)(((intptr_t)addr) + offset); 1595 addr = (void *)(((intptr_t)addr) + offset);
1526 eio_page_align (&addr, &len); 1596 eio_page_align (&addr, &len);
1527#if _POSIX_MEMLOCK 1597#if _POSIX_MEMLOCK_RANGE
1528 RETVAL = munlock (addr, len); 1598 RETVAL = munlock (addr, len);
1529#else 1599#else
1530 RETVAL = ((errno = ENOSYS), -1); 1600 RETVAL = ((errno = ENOSYS), -1);
1531#endif 1601#endif
1532} 1602}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines