Commit a0e639dd authored by gregor herrmann's avatar gregor herrmann

New upstream version 4.50

parent edbb91f1
......@@ -173,7 +173,7 @@ use common::sense;
use base 'Exporter';
BEGIN {
our $VERSION = 4.4;
our $VERSION = 4.5;
our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close
aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx
......@@ -194,7 +194,7 @@ BEGIN {
nreqs nready npending nthreads
max_poll_time max_poll_reqs
sendfile fadvise madvise
mmap munmap munlock munlockall);
mmap munmap mremap munlock munlockall);
push @AIO_REQ, qw(aio_busy); # not exported
......@@ -287,6 +287,7 @@ documentation.
IO::AIO::fadvise $fh, $offset, $len, $advice
IO::AIO::mmap $scalar, $length, $prot, $flags[, $fh[, $offset]]
IO::AIO::munmap $scalar
IO::AIO::mremap $scalar, $new_length, $flags[, $new_address]
IO::AIO::madvise $scalar, $offset, $length, $advice
IO::AIO::mprotect $scalar, $offset, $length, $protect
IO::AIO::munlock $scalar, $offset = 0, $length = undef
......@@ -406,7 +407,7 @@ your system are, as usual, C<0>):
C<O_ASYNC>, C<O_DIRECT>, C<O_NOATIME>, C<O_CLOEXEC>, C<O_NOCTTY>, C<O_NOFOLLOW>,
C<O_NONBLOCK>, C<O_EXEC>, C<O_SEARCH>, C<O_DIRECTORY>, C<O_DSYNC>,
C<O_RSYNC>, C<O_SYNC>, C<O_PATH>, C<O_TMPFILE>, and C<O_TTY_INIT>.
C<O_RSYNC>, C<O_SYNC>, C<O_PATH>, C<O_TMPFILE>, C<O_TTY_INIT> and C<O_ACCMODE>.
=item aio_close $fh, $callback->($status)
......@@ -791,10 +792,10 @@ flags will also be passed to the callback, possibly modified):
=item IO::AIO::READDIR_DENTS
When this flag is off, then the callback gets an arrayref consisting of
names only (as with C<aio_readdir>), otherwise it gets an arrayref with
C<[$name, $type, $inode]> arrayrefs, each describing a single directory
entry in more detail.
Normally the callback gets an arrayref consisting of names only (as
with C<aio_readdir>). If this flag is set, then the callback gets an
arrayref with C<[$name, $type, $inode]> arrayrefs, each describing a
single directory entry in more detail:
C<$name> is the name of the entry.
......@@ -804,9 +805,9 @@ C<IO::AIO::DT_UNKNOWN>, C<IO::AIO::DT_FIFO>, C<IO::AIO::DT_CHR>, C<IO::AIO::DT_D
C<IO::AIO::DT_BLK>, C<IO::AIO::DT_REG>, C<IO::AIO::DT_LNK>, C<IO::AIO::DT_SOCK>,
C<IO::AIO::DT_WHT>.
C<IO::AIO::DT_UNKNOWN> means just that: readdir does not know. If you need to
know, you have to run stat yourself. Also, for speed reasons, the C<$type>
scalars are read-only: you can not modify them.
C<IO::AIO::DT_UNKNOWN> means just that: readdir does not know. If you need
to know, you have to run stat yourself. Also, for speed/memory reasons,
the C<$type> scalars are read-only: you must not modify them.
C<$inode> is the inode number (which might not be exact on systems with 64
bit inode numbers and 32 bit perls). This field has unspecified content on
......@@ -827,12 +828,14 @@ short names are tried first.
=item IO::AIO::READDIR_STAT_ORDER
When this flag is set, then the names will be returned in an order
suitable for stat()'ing each one. That is, when you plan to stat()
all files in the given directory, then the returned order will likely
be fastest.
suitable for stat()'ing each one. That is, when you plan to stat() most or
all files in the given directory, then the returned order will likely be
faster.
If both this flag and C<IO::AIO::READDIR_DIRS_FIRST> are specified, then
the likely dirs come first, resulting in a less optimal stat order.
If both this flag and C<IO::AIO::READDIR_DIRS_FIRST> are specified,
then the likely dirs come first, resulting in a less optimal stat order
for stat'ing all entries, but likely a more optimal order for finding
subdirectories.
=item IO::AIO::READDIR_FOUND_UNKNOWN
......@@ -2158,6 +2161,29 @@ Example:
Removes a previous mmap and undefines the C<$scalar>.
=item IO::AIO::mremap $scalar, $new_length, $flags = MREMAP_MAYMOVE[, $new_address = 0]
Calls the Linux-specific mremap(2) system call. The C<$scalar> must have
been mapped by C<IO::AIO::mmap>, and C<$flags> must currently either be
C<0> or C<IO::AIO::MREMAP_MAYMOVE>.
Returns true if successful, and false otherwise. If the underlying mmapped
region has changed address, then the true value has the numerical value
C<1>, otherwise it has the numerical value C<0>:
my $success = IO::AIO::mremap $mmapped, 8192, IO::AIO::MREMAP_MAYMOVE
or die "mremap: $!";
if ($success*1) {
warn "scalar has chanegd address in memory\n";
}
C<IO::AIO::MREMAP_FIXED> and the C<$new_address> argument are currently
implemented, but not supported and might go away in a future version.
On systems where this call is not supported or is not emulated, this call
returns falls and sets C<$!> to C<ENOSYS>.
=item IO::AIO::munlock $scalar, $offset = 0, $length = undef
Calls the C<munlock> function, undoing the effects of a previous
......
......@@ -6,10 +6,15 @@
#include "perl.h"
#include "XSUB.h"
#if !defined mg_findext
# define mg_findext(sv,type,vtbl) mg_find (sv, type)
#endif
#include <stddef.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <limits.h>
#include <fcntl.h>
......@@ -161,10 +166,6 @@ static void req_destroy (eio_req *grp);
# endif
#endif
/* defines all sorts of constants to 0 unless they are already defined */
/* also provides const_iv_ and const_niv_ macros for them */
#include "def0.h"
#ifndef makedev
# define makedev(maj,min) (((maj) << 8) | (min))
#endif
......@@ -182,7 +183,7 @@ static void req_destroy (eio_req *grp);
/*****************************************************************************/
#if !_POSIX_MAPPED_FILES
# define mmap(addr,length,prot,flags,fd,offs) EIO_ENOSYS ()
# define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, (void *)-1)
# define munmap(addr,length) EIO_ENOSYS ()
#endif
......@@ -190,6 +191,10 @@ static void req_destroy (eio_req *grp);
# define mprotect(addr,len,prot) EIO_ENOSYS ()
#endif
#if !MREMAP_MAYMOVE
# define mremap(old_address,old_size,new_size,flags,new_address) (errno = ENOSYS, (void *)-1)
#endif
#define FOREIGN_MAGIC PERL_MAGIC_ext
static int ecb_cold
......@@ -272,6 +277,12 @@ sv_clear_foreign (SV *sv)
/*****************************************************************************/
/* defines all sorts of constants to 0 unless they are already defined */
/* also provides const_iv_ and const_niv_ macros for them */
#include "def0.h"
/*****************************************************************************/
static void
fiemap (eio_req *req)
{
......@@ -1036,6 +1047,8 @@ BOOT:
const_niv (MADV_DONTNEED , POSIX_MADV_DONTNEED)
/* the second block will be 0 when missing */
const_iv (O_ACCMODE)
const_iv (O_RDONLY)
const_iv (O_WRONLY)
const_iv (O_RDWR)
......@@ -1105,8 +1118,14 @@ BOOT:
const_iv (MAP_HUGETLB)
const_iv (MAP_STACK)
const_iv (MREMAP_MAYMOVE)
const_iv (MREMAP_FIXED)
const_iv (F_DUPFD_CLOEXEC)
const_iv (MSG_CMSG_CLOEXEC)
const_iv (SOCK_CLOEXEC)
const_iv (F_OFD_GETLK)
const_iv (F_OFD_SETLK)
const_iv (F_OFD_GETLKW)
......@@ -2059,6 +2078,36 @@ munmap (SV *scalar)
CODE:
sv_clear_foreign (scalar);
SV *
mremap (SV *scalar, STRLEN new_length, int flags = MREMAP_MAYMOVE, IV new_address = 0)
CODE:
{
MAGIC *mg = mg_findext (scalar, FOREIGN_MAGIC, &mmap_vtbl);
void *new;
if (!mg || SvPVX (scalar) != mg->mg_ptr)
croak ("IO::AIO::mremap: scalar not mapped by IO::AIO::mmap or improperly modified");
new = mremap (mg->mg_ptr, (size_t)mg->mg_obj, new_length, flags, (void *)new_address);
RETVAL = &PL_sv_no;
if (new != (void *)-1)
{
RETVAL = new == (void *)mg->mg_ptr
? newSVpvn ("0 but true", 10)
: &PL_sv_yes;
mg->mg_ptr = (char *)new;
mg->mg_obj = (SV *)new_length;
SvPVX (scalar) = mg->mg_ptr;
SvCUR_set (scalar, new_length);
}
}
OUTPUT:
RETVAL
int
madvise (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot)
ALIAS:
......
......@@ -25,6 +25,7 @@ TODO: rewrite rmtree et al. to support working directories (also speed them up)
TODO: maybe IO::AIO leaks fds when requests are cancelled? maybe initialise result to -1?
TODO: aio_wd should use O_PATH on linux, due to lacking O_SEARCH (http://comments.gmane.org/gmane.linux.file-systems/33611)
http://www.openwall.com/lists/musl/2013/02/23/4
TODO: maybe copy some hacks from PerlIOStdio_invalidate_fileno for faster close on certain platforms
TODO: copy_file_range, copy_file_range
TODO: FIDEDUPERANGE, file_ioctl.c
TODO: mincore
......@@ -33,6 +34,15 @@ TODO: unlinkat flags, linkat flags, statat flags
TODO: https://kernelnewbies.org/Linux_4.11
TODO: define useful rules for [[$wd, $path], $path] &c and implement them
TODO: https://github.com/coreutils/coreutils/blob/master/src/stat.c maybe IO::AIO::FSID
TODO: mlock2, MLOCK_ONFAULT
TODO: dup3, pipe2, accept4
4.5 Wed Aug 1 00:23:55 CEST 2018
- aio_mtouch touch all pages as requested, not just the first page in most cases.
- new function: IO::AIO::mremap, linux-specific mremap, with constants MREMAP_MAYMOVE
and MREMAP_FIXED.
- add O_ACCMODE.
- add (undocumented) MSG_CMSG_CLOEXEC and SOCK_CLOEXEC constants.
4.4 Tue Feb 20 07:54:12 CET 2018
- new aio_slurp request.
......
......@@ -4,7 +4,7 @@
"unknown"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010",
"generated_by" : "ExtUtils::MakeMaker version 7.32, CPAN::Meta::Converter version 2.150010",
"license" : [
"unknown"
],
......@@ -38,6 +38,6 @@
}
},
"release_status" : "stable",
"version" : 4.4,
"version" : 4.5,
"x_serialization_backend" : "JSON::PP version 2.27300"
}
......@@ -8,7 +8,7 @@ configure_requires:
Canary::Stability: '2001'
ExtUtils::MakeMaker: '6.52'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010'
generated_by: 'ExtUtils::MakeMaker version 7.32, CPAN::Meta::Converter version 2.150010'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
......@@ -20,5 +20,5 @@ no_index:
- inc
requires:
common::sense: '0'
version: 4.4
version: 4.5
x_serialization_backend: 'CPAN::Meta::YAML version 0.012'
......@@ -230,6 +230,7 @@ FUNCTIONS
IO::AIO::fadvise $fh, $offset, $len, $advice
IO::AIO::mmap $scalar, $length, $prot, $flags[, $fh[, $offset]]
IO::AIO::munmap $scalar
IO::AIO::mremap $scalar, $new_length, $flags[, $new_address]
IO::AIO::madvise $scalar, $offset, $length, $advice
IO::AIO::mprotect $scalar, $offset, $length, $protect
IO::AIO::munlock $scalar, $offset = 0, $length = undef
......@@ -341,8 +342,8 @@ FUNCTIONS
"O_ASYNC", "O_DIRECT", "O_NOATIME", "O_CLOEXEC", "O_NOCTTY",
"O_NOFOLLOW", "O_NONBLOCK", "O_EXEC", "O_SEARCH", "O_DIRECTORY",
"O_DSYNC", "O_RSYNC", "O_SYNC", "O_PATH", "O_TMPFILE", and
"O_TTY_INIT".
"O_DSYNC", "O_RSYNC", "O_SYNC", "O_PATH", "O_TMPFILE", "O_TTY_INIT"
and "O_ACCMODE".
aio_close $fh, $callback->($status)
Asynchronously close a file and call the callback with the result
......@@ -688,10 +689,10 @@ FUNCTIONS
modified):
IO::AIO::READDIR_DENTS
When this flag is off, then the callback gets an arrayref
consisting of names only (as with "aio_readdir"), otherwise it
Normally the callback gets an arrayref consisting of names only
(as with "aio_readdir"). If this flag is set, then the callback
gets an arrayref with "[$name, $type, $inode]" arrayrefs, each
describing a single directory entry in more detail.
describing a single directory entry in more detail:
$name is the name of the entry.
......@@ -702,9 +703,9 @@ FUNCTIONS
"IO::AIO::DT_LNK", "IO::AIO::DT_SOCK", "IO::AIO::DT_WHT".
"IO::AIO::DT_UNKNOWN" means just that: readdir does not know. If
you need to know, you have to run stat yourself. Also, for speed
reasons, the $type scalars are read-only: you can not modify
them.
you need to know, you have to run stat yourself. Also, for
speed/memory reasons, the $type scalars are read-only: you must
not modify them.
$inode is the inode number (which might not be exact on systems
with 64 bit inode numbers and 32 bit perls). This field has
......@@ -726,12 +727,13 @@ FUNCTIONS
IO::AIO::READDIR_STAT_ORDER
When this flag is set, then the names will be returned in an
order suitable for stat()'ing each one. That is, when you plan
to stat() all files in the given directory, then the returned
order will likely be fastest.
to stat() most or all files in the given directory, then the
returned order will likely be faster.
If both this flag and "IO::AIO::READDIR_DIRS_FIRST" are
specified, then the likely dirs come first, resulting in a less
optimal stat order.
optimal stat order for stat'ing all entries, but likely a more
optimal order for finding subdirectories.
IO::AIO::READDIR_FOUND_UNKNOWN
This flag should not be set when calling "aio_readdirx".
......@@ -1726,6 +1728,30 @@ FUNCTIONS
IO::AIO::munmap $scalar
Removes a previous mmap and undefines the $scalar.
IO::AIO::mremap $scalar, $new_length, $flags = MREMAP_MAYMOVE[,
$new_address = 0]
Calls the Linux-specific mremap(2) system call. The $scalar must
have been mapped by "IO::AIO::mmap", and $flags must currently
either be 0 or "IO::AIO::MREMAP_MAYMOVE".
Returns true if successful, and false otherwise. If the underlying
mmapped region has changed address, then the true value has the
numerical value 1, otherwise it has the numerical value 0:
my $success = IO::AIO::mremap $mmapped, 8192, IO::AIO::MREMAP_MAYMOVE
or die "mremap: $!";
if ($success*1) {
warn "scalar has chanegd address in memory\n";
}
"IO::AIO::MREMAP_FIXED" and the $new_address argument are currently
implemented, but not supported and might go away in a future
version.
On systems where this call is not supported or is not emulated, this
call returns falls and sets $! to "ENOSYS".
IO::AIO::munlock $scalar, $offset = 0, $length = undef
Calls the "munlock" function, undoing the effects of a previous
"aio_mlock" call (see its description for details).
......
......@@ -48,6 +48,9 @@
#ifndef POSIX_MADV_DONTNEED
#define POSIX_MADV_DONTNEED 0
#endif
#ifndef O_ACCMODE
#define O_ACCMODE 0
#endif
#ifndef O_RDONLY
#define O_RDONLY 0
#endif
......@@ -228,9 +231,21 @@
#ifndef MAP_STACK
#define MAP_STACK 0
#endif
#ifndef MREMAP_MAYMOVE
#define MREMAP_MAYMOVE 0
#endif
#ifndef MREMAP_FIXED
#define MREMAP_FIXED 0
#endif
#ifndef F_DUPFD_CLOEXEC
#define F_DUPFD_CLOEXEC 0
#endif
#ifndef MSG_CMSG_CLOEXEC
#define MSG_CMSG_CLOEXEC 0
#endif
#ifndef SOCK_CLOEXEC
#define SOCK_CLOEXEC 0
#endif
#ifndef F_OFD_GETLK
#define F_OFD_GETLK 0
#endif
......
......@@ -961,9 +961,9 @@ eio__mtouch (eio_req *req)
if (addr < end)
if (flags & EIO_MT_MODIFY) /* modify */
do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < len && !EIO_CANCELLED (req));
do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < end && !EIO_CANCELLED (req));
else
do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < len && !EIO_CANCELLED (req));
do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < end && !EIO_CANCELLED (req));
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment