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.255 by root, Tue Feb 20 06:05:19 2018 UTC vs.
Revision 1.258 by root, Wed Jul 18 00:57:55 2018 UTC

3#include <errno.h> 3#include <errno.h>
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
9#if !defined mg_findext
10# define mg_findext(sv,type,vtbl) mg_find (sv, type)
11#endif
8 12
9#include <stddef.h> 13#include <stddef.h>
10#include <stdlib.h> 14#include <stdlib.h>
11#include <errno.h> 15#include <errno.h>
12#include <sys/types.h> 16#include <sys/types.h>
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 ()
191#endif 195#endif
192 196
197#if !MREMAP_MAYMOVE
198# define mremap(old_address,old_size,new_size,flags,new_address) (errno = ENOSYS, (void *)-1)
199#endif
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
196mmap_free (pTHX_ SV *sv, MAGIC *mg) 204mmap_free (pTHX_ SV *sv, MAGIC *mg)
197{ 205{
1102 const_iv (MAP_NONBLOCK) 1110 const_iv (MAP_NONBLOCK)
1103 const_iv (MAP_GROWSDOWN) 1111 const_iv (MAP_GROWSDOWN)
1104 const_iv (MAP_32BIT) 1112 const_iv (MAP_32BIT)
1105 const_iv (MAP_HUGETLB) 1113 const_iv (MAP_HUGETLB)
1106 const_iv (MAP_STACK) 1114 const_iv (MAP_STACK)
1115
1116 const_iv (MREMAP_MAYMOVE)
1117 const_iv (MREMAP_FIXED)
1107 1118
1108 const_iv (F_DUPFD_CLOEXEC) 1119 const_iv (F_DUPFD_CLOEXEC)
1109 1120
1110 const_iv (F_OFD_GETLK) 1121 const_iv (F_OFD_GETLK)
1111 const_iv (F_OFD_SETLK) 1122 const_iv (F_OFD_SETLK)
2057void 2068void
2058munmap (SV *scalar) 2069munmap (SV *scalar)
2059 CODE: 2070 CODE:
2060 sv_clear_foreign (scalar); 2071 sv_clear_foreign (scalar);
2061 2072
2073SV *
2074mremap (SV *scalar, STRLEN new_length, int flags = 0, IV new_address = 0)
2075 CODE:
2076{
2077 MAGIC *mg = mg_findext (scalar, FOREIGN_MAGIC, &mmap_vtbl);
2078 void *new;
2079
2080 if (!mg || SvPVX (scalar) != mg->mg_ptr)
2081 croak ("IO::AIO::mremap: scalar not mapped by IO::AIO::mmap or improperly modified");
2082
2083 new = mremap (mg->mg_ptr, (size_t)mg->mg_obj, new_length, flags, (void *)new_address);
2084
2085 RETVAL = &PL_sv_no;
2086
2087 if (new != (void *)-1)
2088 {
2089 RETVAL = new == (void *)mg->mg_ptr
2090 ? newSVpvn ("0 but true", 10)
2091 : &PL_sv_yes;
2092
2093 mg->mg_ptr = (char *)new;
2094 mg->mg_obj = (SV *)new_length;
2095
2096 SvPVX (scalar) = mg->mg_ptr;
2097 SvCUR_set (scalar, new_length);
2098 }
2099}
2100 OUTPUT:
2101 RETVAL
2102
2062int 2103int
2063madvise (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) 2104madvise (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot)
2064 ALIAS: 2105 ALIAS:
2065 mprotect = 1 2106 mprotect = 1
2066 CODE: 2107 CODE:
2230void 2271void
2231timerfd_settime (SV *fh, int flags, NV interval, NV value) 2272timerfd_settime (SV *fh, int flags, NV interval, NV value)
2232 PPCODE: 2273 PPCODE:
2233{ 2274{
2234 int fd = s_fileno_croak (fh, 0); 2275 int fd = s_fileno_croak (fh, 0);
2276#if HAVE_TIMERFD
2235 int res; 2277 int res;
2236 struct itimerspec its, ots; 2278 struct itimerspec its, ots;
2237 2279
2238 ts_set (&its.it_interval, interval); 2280 ts_set (&its.it_interval, interval);
2239 ts_set (&its.it_value , value); 2281 ts_set (&its.it_value , value);
2240#if HAVE_TIMERFD
2241 res = timerfd_settime (fd, flags, &its, &ots); 2282 res = timerfd_settime (fd, flags, &its, &ots);
2242#else
2243 res = (errno = ENOSYS, -1);
2244#endif
2245 2283
2246 if (!res) 2284 if (!res)
2247 { 2285 {
2248 EXTEND (SP, 2); 2286 EXTEND (SP, 2);
2249 PUSHs (newSVnv (ts_get (&ots.it_interval))); 2287 PUSHs (newSVnv (ts_get (&ots.it_interval)));
2250 PUSHs (newSVnv (ts_get (&ots.it_value))); 2288 PUSHs (newSVnv (ts_get (&ots.it_value)));
2251 } 2289 }
2290#else
2291 errno = ENOSYS;
2292#endif
2252} 2293}
2253 2294
2254void 2295void
2255timerfd_gettime (SV *fh) 2296timerfd_gettime (SV *fh)
2256 PPCODE: 2297 PPCODE:
2257{ 2298{
2258 int fd = s_fileno_croak (fh, 0); 2299 int fd = s_fileno_croak (fh, 0);
2300#if HAVE_TIMERFD
2259 int res; 2301 int res;
2260 struct itimerspec ots; 2302 struct itimerspec ots;
2261#if HAVE_TIMERFD
2262 res = timerfd_gettime (fd, &ots); 2303 res = timerfd_gettime (fd, &ots);
2263#else
2264 res = (errno = ENOSYS, -1);
2265#endif
2266 2304
2267 if (!res) 2305 if (!res)
2268 { 2306 {
2269 EXTEND (SP, 2); 2307 EXTEND (SP, 2);
2270 PUSHs (newSVnv (ts_get (&ots.it_interval))); 2308 PUSHs (newSVnv (ts_get (&ots.it_interval)));
2271 PUSHs (newSVnv (ts_get (&ots.it_value))); 2309 PUSHs (newSVnv (ts_get (&ots.it_value)));
2272 } 2310 }
2311#else
2312 errno = ENOSYS;
2313#endif
2273} 2314}
2274 2315
2275UV 2316UV
2276get_fdlimit () 2317get_fdlimit ()
2277 CODE: 2318 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines