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.256 by root, Tue Feb 20 06:54:46 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:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines