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.179 by root, Fri Jan 7 21:47:15 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
354 /* do not recreate the result IV from scratch each time */ 353 /* do not recreate the result IV from scratch each time */
355 if (expect_true (sv_result_cache)) 354 if (expect_true (sv_result_cache))
356 { 355 {
357 sv_result = sv_result_cache; sv_result_cache = 0; 356 sv_result = sv_result_cache; sv_result_cache = 0;
358 SvIV_set (sv_result, req->result); 357 SvIV_set (sv_result, req->result);
358 SvIOK_only (sv_result);
359 } 359 }
360 else 360 else
361 { 361 {
362 sv_result = newSViv (req->result); 362 sv_result = newSViv (req->result);
363 SvREADONLY_on (sv_result); 363 SvREADONLY_on (sv_result);
527 SvSETMAGIC (req->sv2); 527 SvSETMAGIC (req->sv2);
528 PUSHs (sv_result); 528 PUSHs (sv_result);
529 } 529 }
530 break; 530 break;
531 531
532 case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), su fudge result value */ 532 case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), so fudge result value */
533 if (req->result > 0) 533 if (req->result > 0)
534 SvIV_set (sv_result, 0); 534 SvIV_set (sv_result, 0);
535 /* FALLTHROUGH */ 535 /* FALLTHROUGH */
536 536
537 default: 537 default:
637/*****************************************************************************/ 637/*****************************************************************************/
638 638
639#if !_POSIX_MAPPED_FILES 639#if !_POSIX_MAPPED_FILES
640# define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) 640# define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1)
641# define munmap(addr,length) (errno = ENOSYS, -1) 641# define munmap(addr,length) (errno = ENOSYS, -1)
642#endif
643
644#if !_POSIX_MEMORY_PROTECTION
642# define mprotect(addr,len,prot) (errno = ENOSYS, -1) 645# define mprotect(addr,len,prot) (errno = ENOSYS, -1)
646# define PROT_NONE 0
647# define PROT_WRITE 0
648# define MAP_PRIVATE 0
649# define MAP_SHARED 0
650# define MAP_FIXED 0
643#endif 651#endif
644 652
645#define MMAP_MAGIC PERL_MAGIC_ext 653#define MMAP_MAGIC PERL_MAGIC_ext
646 654
647static int 655static int
1257 1265
1258void 1266void
1259aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback=&PL_sv_undef) 1267aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback=&PL_sv_undef)
1260 PPCODE: 1268 PPCODE:
1261{ 1269{
1262
1263 STRLEN svlen; 1270 STRLEN svlen;
1264 char *svptr = SvPVbyte (data, svlen); 1271 char *svptr = SvPVbyte (data, svlen);
1265 UV len = SvUV (length); 1272 UV len = SvUV (length);
1266 1273
1267 if (offset < 0) 1274 if (offset < 0)
1520 if (!SvOK (length) || len + offset > svlen) 1527 if (!SvOK (length) || len + offset > svlen)
1521 len = svlen - offset; 1528 len = svlen - offset;
1522 1529
1523 addr = (void *)(((intptr_t)addr) + offset); 1530 addr = (void *)(((intptr_t)addr) + offset);
1524 eio_page_align (&addr, &len); 1531 eio_page_align (&addr, &len);
1525#if _POSIX_MEMLOCK 1532#if _POSIX_MEMLOCK_RANGE
1526 RETVAL = munlock (addr, len); 1533 RETVAL = munlock (addr, len);
1527#else 1534#else
1528 RETVAL = ((errno = ENOSYS), -1); 1535 RETVAL = ((errno = ENOSYS), -1);
1529#endif 1536#endif
1530} 1537}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines