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.172 by root, Sun Sep 12 03:36:27 2010 UTC vs.
Revision 1.180 by root, Fri Feb 11 00:05:17 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# define NO_FADVISE 1
128#endif 128#endif
129#ifndef POSIX_FADV_SEQUENTIAL 129#ifndef POSIX_FADV_SEQUENTIAL
130# define POSIX_FADV_SEQUENTIAL 0 130# define POSIX_FADV_SEQUENTIAL 0
131#endif 131#endif
132#ifndef POSIX_FADV_RANDOM 132#ifndef POSIX_FADV_RANDOM
140#endif 140#endif
141#ifndef POSIX_FADV_DONTNEED 141#ifndef POSIX_FADV_DONTNEED
142# define POSIX_FADV_DONTNEED 0 142# define POSIX_FADV_DONTNEED 0
143#endif 143#endif
144 144
145#if _XOPEN_SOURCE < 600 || NO_FADVISE 145#if !HAVE_POSIX_FADVISE
146# define posix_fadvise(a,b,c,d) errno = ENOSYS /* also return ENOSYS */ 146# define posix_fadvise(a,b,c,d) errno = ENOSYS /* also return ENOSYS */
147#endif 147#endif
148 148
149#ifndef POSIX_MADV_NORMAL 149#ifndef POSIX_MADV_NORMAL
150# define POSIX_MADV_NORMAL 0 150# define POSIX_MADV_NORMAL 0
151# define NO_MADVISE 1
152#endif 151#endif
153#ifndef POSIX_MADV_SEQUENTIAL 152#ifndef POSIX_MADV_SEQUENTIAL
154# define POSIX_MADV_SEQUENTIAL 0 153# define POSIX_MADV_SEQUENTIAL 0
155#endif 154#endif
156#ifndef POSIX_MADV_RANDOM 155#ifndef POSIX_MADV_RANDOM
161#endif 160#endif
162#ifndef POSIX_MADV_DONTNEED 161#ifndef POSIX_MADV_DONTNEED
163# define POSIX_MADV_DONTNEED 0 162# define POSIX_MADV_DONTNEED 0
164#endif 163#endif
165 164
166#if _XOPEN_SOURCE < 600 || NO_MADVISE 165#if !HAVE_POSIX_MADVISE
167# define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ 166# define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */
168#endif 167#endif
169 168
170#ifndef PROT_NONE 169#ifndef PROT_NONE
171# define PROT_NONE 0 170# define PROT_NONE 0
207#ifndef ST_NODIRATIME 206#ifndef ST_NODIRATIME
208# define ST_NODIRATIME 0 207# define ST_NODIRATIME 0
209#endif 208#endif
210#ifndef ST_RELATIME 209#ifndef ST_RELATIME
211# 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
212#endif 236#endif
213 237
214#ifndef MAP_ANONYMOUS 238#ifndef MAP_ANONYMOUS
215# ifdef MAP_ANON 239# ifdef MAP_ANON
216# define MAP_ANONYMOUS MAP_ANON 240# define MAP_ANONYMOUS MAP_ANON
230#ifndef MAP_POPULATE 254#ifndef MAP_POPULATE
231# define MAP_POPULATE 0 255# define MAP_POPULATE 0
232#endif 256#endif
233#ifndef MAP_NONBLOCK 257#ifndef MAP_NONBLOCK
234# 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)
235#endif 269#endif
236 270
237#ifndef PAGESIZE 271#ifndef PAGESIZE
238# define PAGESIZE sysconf (_SC_PAGESIZE) 272# define PAGESIZE sysconf (_SC_PAGESIZE)
239#endif 273#endif
354 /* do not recreate the result IV from scratch each time */ 388 /* do not recreate the result IV from scratch each time */
355 if (expect_true (sv_result_cache)) 389 if (expect_true (sv_result_cache))
356 { 390 {
357 sv_result = sv_result_cache; sv_result_cache = 0; 391 sv_result = sv_result_cache; sv_result_cache = 0;
358 SvIV_set (sv_result, req->result); 392 SvIV_set (sv_result, req->result);
393 SvIOK_only (sv_result);
359 } 394 }
360 else 395 else
361 { 396 {
362 sv_result = newSViv (req->result); 397 sv_result = newSViv (req->result);
363 SvREADONLY_on (sv_result); 398 SvREADONLY_on (sv_result);
527 SvSETMAGIC (req->sv2); 562 SvSETMAGIC (req->sv2);
528 PUSHs (sv_result); 563 PUSHs (sv_result);
529 } 564 }
530 break; 565 break;
531 566
532 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 */
533 if (req->result > 0) 568 if (req->result > 0)
534 SvIV_set (sv_result, 0); 569 SvIV_set (sv_result, 0);
535 /* FALLTHROUGH */ 570 /* FALLTHROUGH */
536 571
537 default: 572 default:
637/*****************************************************************************/ 672/*****************************************************************************/
638 673
639#if !_POSIX_MAPPED_FILES 674#if !_POSIX_MAPPED_FILES
640# define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) 675# define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1)
641# define munmap(addr,length) (errno = ENOSYS, -1) 676# define munmap(addr,length) (errno = ENOSYS, -1)
677#endif
678
679#if !_POSIX_MEMORY_PROTECTION
642# define mprotect(addr,len,prot) (errno = ENOSYS, -1) 680# define mprotect(addr,len,prot) (errno = ENOSYS, -1)
681# define PROT_NONE 0
682# define PROT_WRITE 0
683# define MAP_PRIVATE 0
684# define MAP_SHARED 0
685# define MAP_FIXED 0
643#endif 686#endif
644 687
645#define MMAP_MAGIC PERL_MAGIC_ext 688#define MMAP_MAGIC PERL_MAGIC_ext
646 689
647static int 690static int
721 const_iv (O_RDWR) 764 const_iv (O_RDWR)
722 const_iv (O_CREAT) 765 const_iv (O_CREAT)
723 const_iv (O_TRUNC) 766 const_iv (O_TRUNC)
724 const_iv (O_EXCL) 767 const_iv (O_EXCL)
725 const_iv (O_APPEND) 768 const_iv (O_APPEND)
726#ifndef _WIN32 769
727 const_iv (S_IFIFO) 770 const_iv (S_IFIFO)
728#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
729 const_niv (FADV_NORMAL , POSIX_FADV_NORMAL) 780 const_niv (FADV_NORMAL , POSIX_FADV_NORMAL)
730 const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL) 781 const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL)
731 const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) 782 const_niv (FADV_RANDOM , POSIX_FADV_RANDOM)
732 const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) 783 const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE)
733 const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) 784 const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED)
1055 } 1106 }
1056 1107
1057 REQ_SEND; 1108 REQ_SEND;
1058} 1109}
1059 1110
1111UV
1112major (UV dev)
1113 ALIAS:
1114 minor = 1
1115 CODE:
1116 RETVAL = ix ? major (dev) : minor (dev);
1117 OUTPUT:
1118 RETVAL
1119
1120UV
1121makedev (UV maj, UV min)
1122 CODE:
1123 RETVAL = makedev (maj, min);
1124 OUTPUT:
1125 RETVAL
1126
1060void 1127void
1061aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) 1128aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef)
1062 PPCODE: 1129 PPCODE:
1063{ 1130{
1064 dREQ; 1131 dREQ;
1257 1324
1258void 1325void
1259aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback=&PL_sv_undef) 1326aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback=&PL_sv_undef)
1260 PPCODE: 1327 PPCODE:
1261{ 1328{
1262
1263 STRLEN svlen; 1329 STRLEN svlen;
1264 char *svptr = SvPVbyte (data, svlen); 1330 char *svptr = SvPVbyte (data, svlen);
1265 UV len = SvUV (length); 1331 UV len = SvUV (length);
1266 1332
1267 if (offset < 0) 1333 if (offset < 0)
1520 if (!SvOK (length) || len + offset > svlen) 1586 if (!SvOK (length) || len + offset > svlen)
1521 len = svlen - offset; 1587 len = svlen - offset;
1522 1588
1523 addr = (void *)(((intptr_t)addr) + offset); 1589 addr = (void *)(((intptr_t)addr) + offset);
1524 eio_page_align (&addr, &len); 1590 eio_page_align (&addr, &len);
1525#if _POSIX_MEMLOCK 1591#if _POSIX_MEMLOCK_RANGE
1526 RETVAL = munlock (addr, len); 1592 RETVAL = munlock (addr, len);
1527#else 1593#else
1528 RETVAL = ((errno = ENOSYS), -1); 1594 RETVAL = ((errno = ENOSYS), -1);
1529#endif 1595#endif
1530} 1596}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines