… | |
… | |
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 |
|
|
146 | # define posix_fadvise(a,b,c,d) errno = ENOSYS /* also return ENOSYS */ |
|
|
147 | #endif |
|
|
148 | |
145 | #ifndef POSIX_MADV_NORMAL |
149 | #ifndef POSIX_MADV_NORMAL |
146 | # define POSIX_MADV_NORMAL 0 |
150 | # define POSIX_MADV_NORMAL 0 |
147 | # define NO_MADVISE 1 |
151 | # define NO_MADVISE 1 |
148 | #endif |
152 | #endif |
149 | #ifndef POSIX_MADV_SEQUENTIAL |
153 | #ifndef POSIX_MADV_SEQUENTIAL |
… | |
… | |
155 | #ifndef POSIX_MADV_WILLNEED |
159 | #ifndef POSIX_MADV_WILLNEED |
156 | # define POSIX_MADV_WILLNEED 0 |
160 | # define POSIX_MADV_WILLNEED 0 |
157 | #endif |
161 | #endif |
158 | #ifndef POSIX_MADV_DONTNEED |
162 | #ifndef POSIX_MADV_DONTNEED |
159 | # define POSIX_MADV_DONTNEED 0 |
163 | # define POSIX_MADV_DONTNEED 0 |
|
|
164 | #endif |
|
|
165 | |
|
|
166 | #if _XOPEN_SOURCE < 600 || NO_MADVISE |
|
|
167 | # define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ |
|
|
168 | #endif |
|
|
169 | |
|
|
170 | #ifndef PROT_NONE |
|
|
171 | # define PROT_NONE 0 |
|
|
172 | #endif |
|
|
173 | #ifndef PROT_READ |
|
|
174 | # define PROT_READ 0 |
|
|
175 | #endif |
|
|
176 | #ifndef PROT_WRITE |
|
|
177 | # define PROT_READ 0 |
|
|
178 | #endif |
|
|
179 | #ifndef PROT_EXEC |
|
|
180 | # define PROT_EXEC 0 |
160 | #endif |
181 | #endif |
161 | |
182 | |
162 | #ifndef ST_NODEV |
183 | #ifndef ST_NODEV |
163 | # define ST_NODEV 0 |
184 | # define ST_NODEV 0 |
164 | #endif |
185 | #endif |
… | |
… | |
623 | /*****************************************************************************/ |
644 | /*****************************************************************************/ |
624 | |
645 | |
625 | #if !_POSIX_MAPPED_FILES |
646 | #if !_POSIX_MAPPED_FILES |
626 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
647 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
627 | # define munmap(addr,length) (errno = ENOSYS, -1) |
648 | # define munmap(addr,length) (errno = ENOSYS, -1) |
|
|
649 | # define mprotect(addr,len,prot) (errno = ENOSYS, -1) |
628 | #endif |
650 | #endif |
629 | |
651 | |
630 | #define MMAP_MAGIC PERL_MAGIC_ext |
652 | #define MMAP_MAGIC PERL_MAGIC_ext |
631 | |
653 | |
632 | static int |
654 | static int |
… | |
… | |
735 | const_iv (ST_IMMUTABLE) |
757 | const_iv (ST_IMMUTABLE) |
736 | const_iv (ST_NOATIME) |
758 | const_iv (ST_NOATIME) |
737 | const_iv (ST_NODIRATIME) |
759 | const_iv (ST_NODIRATIME) |
738 | const_iv (ST_RELATIME) |
760 | const_iv (ST_RELATIME) |
739 | |
761 | |
|
|
762 | const_iv (PROT_NONE) |
740 | const_iv (PROT_EXEC) |
763 | const_iv (PROT_EXEC) |
741 | const_iv (PROT_NONE) |
|
|
742 | const_iv (PROT_READ) |
764 | const_iv (PROT_READ) |
743 | const_iv (PROT_WRITE) |
765 | const_iv (PROT_WRITE) |
744 | |
766 | |
745 | /*const_iv (MAP_FIXED)*/ |
767 | /*const_iv (MAP_FIXED)*/ |
746 | const_iv (MAP_PRIVATE) |
768 | const_iv (MAP_PRIVATE) |
… | |
… | |
1385 | |
1407 | |
1386 | int |
1408 | int |
1387 | fadvise (aio_rfd fh, off_t offset, off_t length, IV advice) |
1409 | fadvise (aio_rfd fh, off_t offset, off_t length, IV advice) |
1388 | PROTOTYPE: $$$$ |
1410 | PROTOTYPE: $$$$ |
1389 | CODE: |
1411 | CODE: |
1390 | #if _XOPEN_SOURCE >= 600 && !NO_FADVISE |
|
|
1391 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1412 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1392 | #else |
|
|
1393 | RETVAL = errno = ENOSYS; /* yes, this is actually correct */ |
|
|
1394 | #endif |
|
|
1395 | OUTPUT: |
1413 | OUTPUT: |
1396 | RETVAL |
1414 | RETVAL |
1397 | |
1415 | |
1398 | ssize_t |
1416 | ssize_t |
1399 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
1417 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
… | |
… | |
1441 | PROTOTYPE: $ |
1459 | PROTOTYPE: $ |
1442 | CODE: |
1460 | CODE: |
1443 | sv_unmagic (scalar, MMAP_MAGIC); |
1461 | sv_unmagic (scalar, MMAP_MAGIC); |
1444 | |
1462 | |
1445 | int |
1463 | int |
1446 | madvise (SV *scalar, off_t offset, off_t length, IV advice) |
1464 | madvise (SV *scalar, off_t offset, off_t length, IV advice_or_prot) |
|
|
1465 | ALIAS: |
|
|
1466 | mprotect = 1 |
1447 | PROTOTYPE: $$$$ |
1467 | PROTOTYPE: $$$$ |
1448 | CODE: |
1468 | CODE: |
1449 | { |
1469 | { |
1450 | char *addr = SvPV_nolen (scalar) + offset; |
1470 | STRLEN cur; |
|
|
1471 | char *addr = SvPVbyte (scalar, cur); |
1451 | |
1472 | |
|
|
1473 | if (offset > cur) |
|
|
1474 | RETVAL = errno = EFAULT; |
|
|
1475 | else |
|
|
1476 | { |
1452 | if (!SvOK (ST (2))) |
1477 | if (!SvOK (ST (2))) |
1453 | length = SvCUR (scalar) - offset; |
1478 | length = cur - offset; |
1454 | |
1479 | |
1455 | if (addr >= SvEND (scalar) || length <= 0) |
1480 | if (offset + length > cur) |
1456 | XSRETURN_EMPTY; |
1481 | RETVAL = errno = EFAULT; |
1457 | |
1482 | else |
1458 | #if _XOPEN_SOURCE >= 600 && !NO_MADVISE |
1483 | switch (ix) |
1459 | RETVAL = posix_madvise (addr, length, advice); |
1484 | { |
1460 | #else |
1485 | case 0: RETVAL = posix_madvise (addr + offset, length, advice_or_prot); break; |
1461 | RETVAL = errno = ENOSYS; /* yes, this is actually correct */ |
1486 | case 1: RETVAL = mprotect (addr + offset, length, advice_or_prot); break; |
1462 | #endif |
1487 | } |
|
|
1488 | } |
1463 | } |
1489 | } |
1464 | OUTPUT: |
1490 | OUTPUT: |
1465 | RETVAL |
1491 | RETVAL |
1466 | |
1492 | |
1467 | int |
1493 | int |