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.254 by root, Tue Feb 20 05:23:47 2018 UTC vs.
Revision 1.259 by root, Sun Jul 22 20:39:19 2018 UTC

4 4
5#include "EXTERN.h" 5#include "EXTERN.h"
6#include "perl.h" 6#include "perl.h"
7#include "XSUB.h" 7#include "XSUB.h"
8 8
9#include "schmorp.h" 9#if !defined mg_findext
10# define mg_findext(sv,type,vtbl) mg_find (sv, type)
11#endif
10 12
11#include <stddef.h> 13#include <stddef.h>
12#include <stdlib.h> 14#include <stdlib.h>
13#include <errno.h> 15#include <errno.h>
14#include <sys/types.h> 16#include <sys/types.h>
106 108
107/*****************************************************************************/ 109/*****************************************************************************/
108 110
109#include "libeio/config.h" 111#include "libeio/config.h"
110 112
113#include "schmorp.h"
114
111#if HAVE_EVENTFD 115#if HAVE_EVENTFD
112# include <sys/eventfd.h> 116# include <sys/eventfd.h>
113#endif 117#endif
114 118
115#if HAVE_TIMERFD 119#if HAVE_TIMERFD
186# define munmap(addr,length) EIO_ENOSYS () 190# define munmap(addr,length) EIO_ENOSYS ()
187#endif 191#endif
188 192
189#if !_POSIX_MEMORY_PROTECTION 193#if !_POSIX_MEMORY_PROTECTION
190# define mprotect(addr,len,prot) EIO_ENOSYS () 194# define mprotect(addr,len,prot) EIO_ENOSYS ()
195#endif
196
197#if !MREMAP_MAYMOVE
198# define mremap(old_address,old_size,new_size,flags,new_address) (errno = ENOSYS, (void *)-1)
191#endif 199#endif
192 200
193#define FOREIGN_MAGIC PERL_MAGIC_ext 201#define FOREIGN_MAGIC PERL_MAGIC_ext
194 202
195static int ecb_cold 203static int ecb_cold
1034 const_niv (MADV_RANDOM , POSIX_MADV_RANDOM) 1042 const_niv (MADV_RANDOM , POSIX_MADV_RANDOM)
1035 const_niv (MADV_WILLNEED , POSIX_MADV_WILLNEED) 1043 const_niv (MADV_WILLNEED , POSIX_MADV_WILLNEED)
1036 const_niv (MADV_DONTNEED , POSIX_MADV_DONTNEED) 1044 const_niv (MADV_DONTNEED , POSIX_MADV_DONTNEED)
1037 1045
1038 /* the second block will be 0 when missing */ 1046 /* the second block will be 0 when missing */
1047 const_iv (O_ACCMODE)
1048
1039 const_iv (O_RDONLY) 1049 const_iv (O_RDONLY)
1040 const_iv (O_WRONLY) 1050 const_iv (O_WRONLY)
1041 const_iv (O_RDWR) 1051 const_iv (O_RDWR)
1042 const_iv (O_CREAT) 1052 const_iv (O_CREAT)
1043 const_iv (O_TRUNC) 1053 const_iv (O_TRUNC)
1102 const_iv (MAP_NONBLOCK) 1112 const_iv (MAP_NONBLOCK)
1103 const_iv (MAP_GROWSDOWN) 1113 const_iv (MAP_GROWSDOWN)
1104 const_iv (MAP_32BIT) 1114 const_iv (MAP_32BIT)
1105 const_iv (MAP_HUGETLB) 1115 const_iv (MAP_HUGETLB)
1106 const_iv (MAP_STACK) 1116 const_iv (MAP_STACK)
1117
1118 const_iv (MREMAP_MAYMOVE)
1119 const_iv (MREMAP_FIXED)
1107 1120
1108 const_iv (F_DUPFD_CLOEXEC) 1121 const_iv (F_DUPFD_CLOEXEC)
1109 1122
1110 const_iv (F_OFD_GETLK) 1123 const_iv (F_OFD_GETLK)
1111 const_iv (F_OFD_SETLK) 1124 const_iv (F_OFD_SETLK)
2057void 2070void
2058munmap (SV *scalar) 2071munmap (SV *scalar)
2059 CODE: 2072 CODE:
2060 sv_clear_foreign (scalar); 2073 sv_clear_foreign (scalar);
2061 2074
2075SV *
2076mremap (SV *scalar, STRLEN new_length, int flags = 0, IV new_address = 0)
2077 CODE:
2078{
2079 MAGIC *mg = mg_findext (scalar, FOREIGN_MAGIC, &mmap_vtbl);
2080 void *new;
2081
2082 if (!mg || SvPVX (scalar) != mg->mg_ptr)
2083 croak ("IO::AIO::mremap: scalar not mapped by IO::AIO::mmap or improperly modified");
2084
2085 new = mremap (mg->mg_ptr, (size_t)mg->mg_obj, new_length, flags, (void *)new_address);
2086
2087 RETVAL = &PL_sv_no;
2088
2089 if (new != (void *)-1)
2090 {
2091 RETVAL = new == (void *)mg->mg_ptr
2092 ? newSVpvn ("0 but true", 10)
2093 : &PL_sv_yes;
2094
2095 mg->mg_ptr = (char *)new;
2096 mg->mg_obj = (SV *)new_length;
2097
2098 SvPVX (scalar) = mg->mg_ptr;
2099 SvCUR_set (scalar, new_length);
2100 }
2101}
2102 OUTPUT:
2103 RETVAL
2104
2062int 2105int
2063madvise (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) 2106madvise (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot)
2064 ALIAS: 2107 ALIAS:
2065 mprotect = 1 2108 mprotect = 1
2066 CODE: 2109 CODE:
2230void 2273void
2231timerfd_settime (SV *fh, int flags, NV interval, NV value) 2274timerfd_settime (SV *fh, int flags, NV interval, NV value)
2232 PPCODE: 2275 PPCODE:
2233{ 2276{
2234 int fd = s_fileno_croak (fh, 0); 2277 int fd = s_fileno_croak (fh, 0);
2278#if HAVE_TIMERFD
2235 int res; 2279 int res;
2236 struct itimerspec its, ots; 2280 struct itimerspec its, ots;
2237 2281
2238 ts_set (&its.it_interval, interval); 2282 ts_set (&its.it_interval, interval);
2239 ts_set (&its.it_value , value); 2283 ts_set (&its.it_value , value);
2240#if HAVE_TIMERFD
2241 res = timerfd_settime (fd, flags, &its, &ots); 2284 res = timerfd_settime (fd, flags, &its, &ots);
2242#else
2243 res = (errno = ENOSYS, -1);
2244#endif
2245 2285
2246 if (!res) 2286 if (!res)
2247 { 2287 {
2248 EXTEND (SP, 2); 2288 EXTEND (SP, 2);
2249 PUSHs (newSVnv (ts_get (&ots.it_interval))); 2289 PUSHs (newSVnv (ts_get (&ots.it_interval)));
2250 PUSHs (newSVnv (ts_get (&ots.it_value))); 2290 PUSHs (newSVnv (ts_get (&ots.it_value)));
2251 } 2291 }
2292#else
2293 errno = ENOSYS;
2294#endif
2252} 2295}
2253 2296
2254void 2297void
2255timerfd_gettime (SV *fh) 2298timerfd_gettime (SV *fh)
2256 PPCODE: 2299 PPCODE:
2257{ 2300{
2258 int fd = s_fileno_croak (fh, 0); 2301 int fd = s_fileno_croak (fh, 0);
2302#if HAVE_TIMERFD
2259 int res; 2303 int res;
2260 struct itimerspec ots; 2304 struct itimerspec ots;
2261#if HAVE_TIMERFD
2262 res = timerfd_gettime (fd, &ots); 2305 res = timerfd_gettime (fd, &ots);
2263#else
2264 res = (errno = ENOSYS, -1);
2265#endif
2266 2306
2267 if (!res) 2307 if (!res)
2268 { 2308 {
2269 EXTEND (SP, 2); 2309 EXTEND (SP, 2);
2270 PUSHs (newSVnv (ts_get (&ots.it_interval))); 2310 PUSHs (newSVnv (ts_get (&ots.it_interval)));
2271 PUSHs (newSVnv (ts_get (&ots.it_value))); 2311 PUSHs (newSVnv (ts_get (&ots.it_value)));
2272 } 2312 }
2313#else
2314 errno = ENOSYS;
2315#endif
2273} 2316}
2274 2317
2275UV 2318UV
2276get_fdlimit () 2319get_fdlimit ()
2277 CODE: 2320 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines