Commit ed0376cf authored by Alessandro Ghedini's avatar Alessandro Ghedini

Imported Upstream version 4.15

parent b49c753e
......@@ -170,13 +170,13 @@ use common::sense;
use base 'Exporter';
BEGIN {
our $VERSION = '4.12';
our $VERSION = '4.15';
our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close
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
aio_scandir aio_symlink aio_readlink aio_realpath aio_sync
aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range aio_fallocate
aio_pathsync aio_readahead
aio_pathsync aio_readahead aio_fiemap
aio_rename aio_link aio_move aio_copy aio_group
aio_nop aio_mknod aio_load aio_rmtree aio_mkdir aio_chown
aio_chmod aio_utime aio_truncate
......@@ -211,6 +211,7 @@ documentation.
aio_wd $pathname, $callback->($wd)
aio_open $pathname, $flags, $mode, $callback->($fh)
aio_close $fh, $callback->($status)
aio_seek $fh,$offset,$whence, $callback->($offs)
aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval)
aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval)
aio_sendfile $out_fh, $in_fh, $in_offset, $length, $callback->($retval)
......@@ -220,8 +221,8 @@ documentation.
aio_statvfs $fh_or_path, $callback->($statvfs)
aio_utime $fh_or_path, $atime, $mtime, $callback->($status)
aio_chown $fh_or_path, $uid, $gid, $callback->($status)
aio_truncate $fh_or_path, $offset, $callback->($status)
aio_chmod $fh_or_path, $mode, $callback->($status)
aio_truncate $fh_or_path, $offset, $callback->($status)
aio_unlink $pathname, $callback->($status)
aio_mknod $pathname, $mode, $dev, $callback->($status)
aio_link $srcpath, $dstpath, $callback->($status)
......@@ -278,7 +279,7 @@ documentation.
IO::AIO::munlock $scalar, $offset = 0, $length = undef
IO::AIO::munlockall
=head2 AIO REQUEST FUNCTIONS
=head2 API NOTES
All the C<aio_*> calls are more or less thin wrappers around the syscall
with the same name (sans C<aio_>). The arguments are similar or identical,
......@@ -319,6 +320,8 @@ correct contents.
This works, btw. independent of the internal UTF-8 bit, which IO::AIO
handles correctly whether it is set or not.
=head2 AIO REQUEST FUNCTIONS
=over 4
=item $prev_pri = aioreq_pri [$pri]
......@@ -410,6 +413,26 @@ free for reuse until the perl filehandle is closed.
=cut
=item aio_seek $fh, $offset, $whence, $callback->($offs)
Seeks the filehandle to the new C<$offset>, similarly to perl's
C<sysseek>. The C<$whence> can use the traditional values (C<0> for
C<IO::AIO::SEEK_SET>, C<1> for C<IO::AIO::SEEK_CUR> or C<2> for
C<IO::AIO::SEEK_END>).
The resulting absolute offset will be passed to the callback, or C<-1> in
case of an error.
In theory, the C<$whence> constants could be different than the
corresponding values from L<Fcntl>, but perl guarantees they are the same,
so don't panic.
As a GNU/Linux (and maybe Solaris) extension, also the constants
C<IO::AIO::SEEK_DATA> and C<IO::AIO::SEEK_HOLE> are available, if they
could be found. No guarantees about suitability for use in C<aio_seek> or
Perl's C<sysseek> can be made though, although I would naively assume they
"just work".
=item aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval)
=item aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval)
......@@ -1234,6 +1257,46 @@ Example: asynchronously lock all current and future pages into memory.
aio_mlockall IO::AIO::MCL_FUTURE;
=item aio_fiemap $fh, $start, $length, $flags, $count, $cb->(\@extents)
Queries the extents of the given file (by calling the Linux FIEMAP ioctl,
see L<http://cvs.schmorp.de/IO-AIO/doc/fiemap.txt> for details). If the
C<ioctl> is not available on your OS, then this rquiest will fail with
C<ENOSYS>.
C<$start> is the starting offset to query extents for, C<$length> is the
size of the range to query - if it is C<undef>, then the whole file will
be queried.
C<$flags> is a combination of flags (C<IO::AIO::FIEMAP_FLAG_SYNC> or
C<IO::AIO::FIEMAP_FLAG_XATTR> - C<IO::AIO::FIEMAP_FLAGS_COMPAT> is also
exported), and is normally C<0> or C<IO::AIO::FIEMAP_FLAG_SYNC> to query
the data portion.
C<$count> is the maximum number of extent records to return. If it is
C<undef>, then IO::AIO queries all extents of the file. As a very special
case, if it is C<0>, then the callback receives the number of extents
instead of the extents themselves.
If an error occurs, the callback receives no arguments. The special
C<errno> value C<IO::AIO::EBADR> is available to test for flag errors.
Otherwise, the callback receives an array reference with extent
structures. Each extent structure is an array reference itself, with the
following members:
[$logical, $physical, $length, $flags]
Flags is any combination of the following flag values (typically either C<0>
or C<IO::AIO::FIEMAP_EXTENT_LAST>):
C<IO::AIO::FIEMAP_EXTENT_LAST>, C<IO::AIO::FIEMAP_EXTENT_UNKNOWN>,
C<IO::AIO::FIEMAP_EXTENT_DELALLOC>, C<IO::AIO::FIEMAP_EXTENT_ENCODED>,
C<IO::AIO::FIEMAP_EXTENT_DATA_ENCRYPTED>, C<IO::AIO::FIEMAP_EXTENT_NOT_ALIGNED>,
C<IO::AIO::FIEMAP_EXTENT_DATA_INLINE>, C<IO::AIO::FIEMAP_EXTENT_DATA_TAIL>,
C<IO::AIO::FIEMAP_EXTENT_UNWRITTEN>, C<IO::AIO::FIEMAP_EXTENT_MERGED> or
C<IO::AIO::FIEMAP_EXTENT_SHARED>.
=item aio_group $callback->(...)
This is a very special aio request: Instead of doing something, it is a
......@@ -1908,6 +1971,23 @@ Calls the C<munlockall> function.
On systems that do not implement C<munlockall>, this function returns
ENOSYS, otherwise the return value of C<munlockall>.
=item IO::AIO::splice $r_fh, $r_off, $w_fh, $w_off, $length, $flags
Calls the GNU/Linux C<splice(2)> syscall, if available. If C<$r_off> or
C<$w_off> are C<undef>, then C<NULL> is passed for these, otherwise they
should be the file offset.
The following symbol flag values are available: C<IO::AIO::SPLICE_F_MOVE>,
C<IO::AIO::SPLICE_F_NONBLOCK>, C<IO::AIO::SPLICE_F_MORE> and
C<IO::AIO::SPLICE_F_GIFT>.
See the C<splice(2)> manpage for details.
=item IO::AIO::tee $r_fh, $w_fh, $length, $flags
Calls the GNU/Linux C<tee(2)> syscall, see it's manpage and the
description for C<IO::AIO::splice> above for details.
=back
=cut
......
This diff is collapsed.
Revision history for IO::AIO
TODO: better autoconf.pm that can return LIBS etc.
TODO: aio_cptree/mvtree
TODO: reduce condvar fairness: schedule hot-cache-threads first?
TODO: splice/tee/vmsplice? (http://kerneltrap.org/node/6505 http://lwn.net/Articles/178199/)
TODO: vmsplice? (http://kerneltrap.org/node/6505 http://lwn.net/Articles/178199/)
TODO: aio_fcntl, at least for file-locking
TODO: aio_mincore?
TODO: getxattr etc.?
TODO: F_DUPFD_CLOEXEC
TODO: emulation for splice?
4.15 Tue Apr 10 06:59:00 CEST 2012
- always include linux/types.h for fiemap, for compatibility to
ancient systems (Paul Howarth).
- experimental support for IO::AIO::splice and ::tee (no aio_...).
- provide SEEK_HOLE and SEEK_DATA, if available.
- work around (again!) an immensely stupid bug in RHEL, defining
autoconf macros in linux system headers (analysed by Paul Howarth).
4.14 Sat Apr 7 02:45:18 CEST 2012
- fix stat structure usage on windows, which caused bogus stat results.
- (libeio) make readahead emulation behave more like actual readahead by never failing.
- new request aio_seek.
- new request aio_fiemap.
- autogenerate the #ifdef/#define 0 blocks for symbols we export.
4.12 Fri Dec 30 08:51:25 CET 2011
- realpath would return a random value if the name was too long,
......
......@@ -6,6 +6,8 @@ Makefile.PL
schmorp.h
AIO.pm
AIO.xs
gendef0
def0.h
bin/treescan
t/00_load.t
t/01_stat.t
......
......@@ -4,7 +4,7 @@
"unknown"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 6.59, CPAN::Meta::Converter version 2.112150",
"generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150",
"license" : [
"unknown"
],
......@@ -37,5 +37,5 @@
}
},
"release_status" : "stable",
"version" : "4.12"
"version" : "4.15"
}
......@@ -7,7 +7,7 @@ build_requires:
configure_requires:
ExtUtils::MakeMaker: 0
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 6.59, CPAN::Meta::Converter version 2.112150'
generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
......@@ -19,4 +19,4 @@ no_index:
- inc
requires:
common::sense: 0
version: 4.12
version: 4.15
......@@ -93,9 +93,9 @@ my $mm = MM->new({
PREOP => 'pod2text AIO.pm | tee README >$(DISTVNAME)/README; chmod -R u=rwX,go=rX . ;',
COMPRESS => 'gzip -9v',
SUFFIX => '.gz',
},
},
depend => {
"AIO.c" => "libeio/eio.h libeio/xthread.h libeio/eio.c libeio/config.h",
"AIO.c" => "schmorp.h libeio/eio.h libeio/xthread.h libeio/eio.c libeio/config.h",
},
NAME => "IO::AIO",
VERSION_FROM => "AIO.pm",
......@@ -103,8 +103,8 @@ my $mm = MM->new({
LIBS => $LIBS,
EXE_FILES => ["bin/treescan"],
PM => {
'AIO.pm' => '$(INST_LIBDIR)/AIO.pm',
},
'AIO.pm' => '$(INST_LIBDIR)/AIO.pm',
},
PREREQ_PM => {
"common::sense" => 0,
},
......
......@@ -155,6 +155,7 @@ FUNCTIONS
aio_wd $pathname, $callback->($wd)
aio_open $pathname, $flags, $mode, $callback->($fh)
aio_close $fh, $callback->($status)
aio_seek $fh,$offset,$whence, $callback->($offs)
aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval)
aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval)
aio_sendfile $out_fh, $in_fh, $in_offset, $length, $callback->($retval)
......@@ -164,8 +165,8 @@ FUNCTIONS
aio_statvfs $fh_or_path, $callback->($statvfs)
aio_utime $fh_or_path, $atime, $mtime, $callback->($status)
aio_chown $fh_or_path, $uid, $gid, $callback->($status)
aio_truncate $fh_or_path, $offset, $callback->($status)
aio_chmod $fh_or_path, $mode, $callback->($status)
aio_truncate $fh_or_path, $offset, $callback->($status)
aio_unlink $pathname, $callback->($status)
aio_mknod $pathname, $mode, $dev, $callback->($status)
aio_link $srcpath, $dstpath, $callback->($status)
......@@ -222,7 +223,7 @@ FUNCTIONS
IO::AIO::munlock $scalar, $offset = 0, $length = undef
IO::AIO::munlockall
AIO REQUEST FUNCTIONS
API NOTES
All the "aio_*" calls are more or less thin wrappers around the syscall
with the same name (sans "aio_"). The arguments are similar or
identical, and they all accept an additional (and optional) $callback
......@@ -262,6 +263,7 @@ FUNCTIONS
This works, btw. independent of the internal UTF-8 bit, which IO::AIO
handles correctly whether it is set or not.
AIO REQUEST FUNCTIONS
$prev_pri = aioreq_pri [$pri]
Returns the priority value that would be used for the next request
and, if $pri is given, sets the priority for the next aio request.
......@@ -343,6 +345,25 @@ FUNCTIONS
Or in other words: the file descriptor will be closed, but it will
not be free for reuse until the perl filehandle is closed.
aio_seek $fh, $offset, $whence, $callback->($offs)
Seeks the filehandle to the new $offset, similarly to perl's
"sysseek". The $whence can use the traditional values (0 for
"IO::AIO::SEEK_SET", 1 for "IO::AIO::SEEK_CUR" or 2 for
"IO::AIO::SEEK_END").
The resulting absolute offset will be passed to the callback, or -1
in case of an error.
In theory, the $whence constants could be different than the
corresponding values from Fcntl, but perl guarantees they are the
same, so don't panic.
As a GNU/Linux (and maybe Solaris) extension, also the constants
"IO::AIO::SEEK_DATA" and "IO::AIO::SEEK_HOLE" are available, if they
could be found. No guarantees about suitability for use in
"aio_seek" or Perl's "sysseek" can be made though, although I would
naively assume they "just work".
aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval)
aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval)
Reads or writes $length bytes from or to the specified $fh and
......@@ -865,6 +886,47 @@ FUNCTIONS
aio_mlockall IO::AIO::MCL_FUTURE;
aio_fiemap $fh, $start, $length, $flags, $count, $cb->(\@extents)
Queries the extents of the given file (by calling the Linux FIEMAP
ioctl, see <http://cvs.schmorp.de/IO-AIO/doc/fiemap.txt> for
details). If the "ioctl" is not available on your OS, then this
rquiest will fail with "ENOSYS".
$start is the starting offset to query extents for, $length is the
size of the range to query - if it is "undef", then the whole file
will be queried.
$flags is a combination of flags ("IO::AIO::FIEMAP_FLAG_SYNC" or
"IO::AIO::FIEMAP_FLAG_XATTR" - "IO::AIO::FIEMAP_FLAGS_COMPAT" is
also exported), and is normally 0 or "IO::AIO::FIEMAP_FLAG_SYNC" to
query the data portion.
$count is the maximum number of extent records to return. If it is
"undef", then IO::AIO queries all extents of the file. As a very
special case, if it is 0, then the callback receives the number of
extents instead of the extents themselves.
If an error occurs, the callback receives no arguments. The special
"errno" value "IO::AIO::EBADR" is available to test for flag errors.
Otherwise, the callback receives an array reference with extent
structures. Each extent structure is an array reference itself, with
the following members:
[$logical, $physical, $length, $flags]
Flags is any combination of the following flag values (typically
either 0 or "IO::AIO::FIEMAP_EXTENT_LAST"):
"IO::AIO::FIEMAP_EXTENT_LAST", "IO::AIO::FIEMAP_EXTENT_UNKNOWN",
"IO::AIO::FIEMAP_EXTENT_DELALLOC", "IO::AIO::FIEMAP_EXTENT_ENCODED",
"IO::AIO::FIEMAP_EXTENT_DATA_ENCRYPTED",
"IO::AIO::FIEMAP_EXTENT_NOT_ALIGNED",
"IO::AIO::FIEMAP_EXTENT_DATA_INLINE",
"IO::AIO::FIEMAP_EXTENT_DATA_TAIL",
"IO::AIO::FIEMAP_EXTENT_UNWRITTEN", "IO::AIO::FIEMAP_EXTENT_MERGED"
or "IO::AIO::FIEMAP_EXTENT_SHARED".
aio_group $callback->(...)
This is a very special aio request: Instead of doing something, it
is a container for other aio requests, which is useful if you want
......@@ -1475,6 +1537,21 @@ FUNCTIONS
On systems that do not implement "munlockall", this function returns
ENOSYS, otherwise the return value of "munlockall".
IO::AIO::splice $r_fh, $r_off, $w_fh, $w_off, $length, $flags
Calls the GNU/Linux splice(2) syscall, if available. If $r_off or
$w_off are "undef", then "NULL" is passed for these, otherwise they
should be the file offset.
The following symbol flag values are available:
"IO::AIO::SPLICE_F_MOVE", "IO::AIO::SPLICE_F_NONBLOCK",
"IO::AIO::SPLICE_F_MORE" and "IO::AIO::SPLICE_F_GIFT".
See the splice(2) manpage for details.
IO::AIO::tee $r_fh, $w_fh, $length, $flags
Calls the GNU/Linux tee(2) syscall, see it's manpage and the
description for "IO::AIO::splice" above for details.
EVENT LOOP INTEGRATION
It is recommended to use AnyEvent::AIO to integrate IO::AIO
automatically into many event loops:
......
This diff is collapsed.
AC_PREREQ(2.59)
AC_INIT
AC_CONFIG_SRCDIR([libeio/eio.h])
AC_CONFIG_HEADERS([libeio/config.h])
AC_PREREQ(2.60)
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
m4_include([libeio/libeio.m4])
......
#ifndef ENOSYS
#define ENOSYS 0
#endif
#ifndef EXDEV
#define EXDEV 0
#endif
#ifndef EBADR
#define EBADR 0
#endif
#ifndef O_RDONLY
#define O_RDONLY 0
#endif
#ifndef O_WRONLY
#define O_WRONLY 0
#endif
#ifndef O_RDWR
#define O_RDWR 0
#endif
#ifndef O_CREAT
#define O_CREAT 0
#endif
#ifndef O_TRUNC
#define O_TRUNC 0
#endif
#ifndef O_EXCL
#define O_EXCL 0
#endif
#ifndef O_APPEND
#define O_APPEND 0
#endif
#ifndef O_ASYNC
#define O_ASYNC 0
#endif
#ifndef O_DIRECT
#define O_DIRECT 0
#endif
#ifndef O_NOATIME
#define O_NOATIME 0
#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
#ifndef O_NOCTTY
#define O_NOCTTY 0
#endif
#ifndef O_NOFOLLOW
#define O_NOFOLLOW 0
#endif
#ifndef O_NONBLOCK
#define O_NONBLOCK 0
#endif
#ifndef O_EXEC
#define O_EXEC 0
#endif
#ifndef O_SEARCH
#define O_SEARCH 0
#endif
#ifndef O_DIRECTORY
#define O_DIRECTORY 0
#endif
#ifndef O_DSYNC
#define O_DSYNC 0
#endif
#ifndef O_RSYNC
#define O_RSYNC 0
#endif
#ifndef O_SYNC
#define O_SYNC 0
#endif
#ifndef O_TTY_INIT
#define O_TTY_INIT 0
#endif
#ifndef S_IFIFO
#define S_IFIFO 0
#endif
#ifndef S_IFCHR
#define S_IFCHR 0
#endif
#ifndef S_IFBLK
#define S_IFBLK 0
#endif
#ifndef S_IFLNK
#define S_IFLNK 0
#endif
#ifndef S_IFREG
#define S_IFREG 0
#endif
#ifndef S_IFDIR
#define S_IFDIR 0
#endif
#ifndef S_IFWHT
#define S_IFWHT 0
#endif
#ifndef S_IFSOCK
#define S_IFSOCK 0
#endif
#ifndef S_IFMT
#define S_IFMT 0
#endif
#ifndef POSIX_FADV_NORMAL
#define POSIX_FADV_NORMAL 0
#endif
#ifndef POSIX_FADV_SEQUENTIAL
#define POSIX_FADV_SEQUENTIAL 0
#endif
#ifndef POSIX_FADV_RANDOM
#define POSIX_FADV_RANDOM 0
#endif
#ifndef POSIX_FADV_NOREUSE
#define POSIX_FADV_NOREUSE 0
#endif
#ifndef POSIX_FADV_WILLNEED
#define POSIX_FADV_WILLNEED 0
#endif
#ifndef POSIX_FADV_DONTNEED
#define POSIX_FADV_DONTNEED 0
#endif
#ifndef POSIX_MADV_NORMAL
#define POSIX_MADV_NORMAL 0
#endif
#ifndef POSIX_MADV_SEQUENTIAL
#define POSIX_MADV_SEQUENTIAL 0
#endif
#ifndef POSIX_MADV_RANDOM
#define POSIX_MADV_RANDOM 0
#endif
#ifndef POSIX_MADV_WILLNEED
#define POSIX_MADV_WILLNEED 0
#endif
#ifndef POSIX_MADV_DONTNEED
#define POSIX_MADV_DONTNEED 0
#endif
#ifndef ST_RDONLY
#define ST_RDONLY 0
#endif
#ifndef ST_NOSUID
#define ST_NOSUID 0
#endif
#ifndef ST_NODEV
#define ST_NODEV 0
#endif
#ifndef ST_NOEXEC
#define ST_NOEXEC 0
#endif
#ifndef ST_SYNCHRONOUS
#define ST_SYNCHRONOUS 0
#endif
#ifndef ST_MANDLOCK
#define ST_MANDLOCK 0
#endif
#ifndef ST_WRITE
#define ST_WRITE 0
#endif
#ifndef ST_APPEND
#define ST_APPEND 0
#endif
#ifndef ST_IMMUTABLE
#define ST_IMMUTABLE 0
#endif
#ifndef ST_NOATIME
#define ST_NOATIME 0
#endif
#ifndef ST_NODIRATIME
#define ST_NODIRATIME 0
#endif
#ifndef ST_RELATIME
#define ST_RELATIME 0
#endif
#ifndef PROT_NONE
#define PROT_NONE 0
#endif
#ifndef PROT_EXEC
#define PROT_EXEC 0
#endif
#ifndef PROT_READ
#define PROT_READ 0
#endif
#ifndef PROT_WRITE
#define PROT_WRITE 0
#endif
#ifndef MAP_PRIVATE
#define MAP_PRIVATE 0
#endif
#ifndef MAP_SHARED
#define MAP_SHARED 0
#endif
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS 0
#endif
#ifndef MAP_HUGETLB
#define MAP_HUGETLB 0
#endif
#ifndef MAP_LOCKED
#define MAP_LOCKED 0
#endif
#ifndef MAP_NORESERVE
#define MAP_NORESERVE 0
#endif
#ifndef MAP_POPULATE
#define MAP_POPULATE 0
#endif
#ifndef MAP_NONBLOCK
#define MAP_NONBLOCK 0
#endif
#ifndef FIEMAP_FLAG_SYNC
#define FIEMAP_FLAG_SYNC 0
#endif
#ifndef FIEMAP_FLAG_XATTR
#define FIEMAP_FLAG_XATTR 0
#endif
#ifndef FIEMAP_FLAGS_COMPAT
#define FIEMAP_FLAGS_COMPAT 0
#endif
#ifndef FIEMAP_EXTENT_LAST
#define FIEMAP_EXTENT_LAST 0
#endif
#ifndef FIEMAP_EXTENT_UNKNOWN
#define FIEMAP_EXTENT_UNKNOWN 0
#endif
#ifndef FIEMAP_EXTENT_DELALLOC
#define FIEMAP_EXTENT_DELALLOC 0
#endif
#ifndef FIEMAP_EXTENT_ENCODED
#define FIEMAP_EXTENT_ENCODED 0
#endif
#ifndef FIEMAP_EXTENT_DATA_ENCRYPTED
#define FIEMAP_EXTENT_DATA_ENCRYPTED 0
#endif
#ifndef FIEMAP_EXTENT_NOT_ALIGNED
#define FIEMAP_EXTENT_NOT_ALIGNED 0
#endif
#ifndef FIEMAP_EXTENT_DATA_INLINE
#define FIEMAP_EXTENT_DATA_INLINE 0
#endif
#ifndef FIEMAP_EXTENT_DATA_TAIL
#define FIEMAP_EXTENT_DATA_TAIL 0
#endif
#ifndef FIEMAP_EXTENT_UNWRITTEN
#define FIEMAP_EXTENT_UNWRITTEN 0
#endif
#ifndef FIEMAP_EXTENT_MERGED
#define FIEMAP_EXTENT_MERGED 0
#endif
#ifndef FIEMAP_EXTENT_SHARED
#define FIEMAP_EXTENT_SHARED 0
#endif
#ifndef SPLICE_F_MOVE
#define SPLICE_F_MOVE 0
#endif
#ifndef SPLICE_F_NONBLOCK
#define SPLICE_F_NONBLOCK 0
#endif
#ifndef SPLICE_F_MORE
#define SPLICE_F_MORE 0
#endif
#ifndef SPLICE_F_GIFT
#define SPLICE_F_GIFT 0
#endif
#ifndef SEEK_DATA
#define SEEK_DATA 0
#endif
#ifndef SEEK_HOLE
#define SEEK_HOLE 0
#endif
#!/usr/bin/perl
open STDIN, "<AIO.xs"
or die "AIO.xs: $!";
open STDOUT, ">def0.h"
or die "def0.h: $!";
while (<>) {
if (/^\s*const_iv\s*\((\S+)\)\s*$/ || /^\s*const_niv\s*\([^,]+,\s*(\S+)\)\s*$/) {
print "#ifndef $1\n",
"#define $1 0\n",
"#endif\n";
}
}
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* fallocate(2) is available */
#undef HAVE_FALLOCATE
/* libeio/config.h.in. Generated from configure.ac by autoheader. */
/* fdatasync(2) is available */
#undef HAVE_FDATASYNC
......@@ -15,6 +9,18 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* fallocate(2) is available */
#undef HAVE_LINUX_FALLOCATE
/* Define to 1 if you have the <linux/fiemap.h> header file. */
#undef HAVE_LINUX_FIEMAP_H
/* Define to 1 if you have the <linux/fs.h> header file. */
#undef HAVE_LINUX_FS_H
/* splice/vmsplice/tee(2) are available */
#undef HAVE_LINUX_SPLICE
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
......@@ -72,13 +78,6 @@
/* utimes(2) is available */
#undef HAVE_UTIMES
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
......@@ -122,9 +121,6 @@
#endif
/* Version number of package */
#undef VERSION
/* Define to 1 if on MINIX. */
#undef _MINIX
......
/*
* libeio implementation
*
* Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libeio@schmorp.de>
* Copyright (c) 2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann <libeio@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
......@@ -210,7 +210,7 @@ static void eio_destroy (eio_req *req);
#define D_NAME(entp) entp->d_name
/* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */
#if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
#if __FreeBSD__ || __NetBSD__ || __OpenBSD__
#define _DIRENT_HAVE_D_TYPE /* sigh */
#define D_INO(de) (de)->d_fileno
#define D_NAMLEN(de) (de)->d_namlen
......@@ -1034,8 +1034,7 @@ eio__syncfs (int fd)
#if HAVE_SYS_SYNCFS
res = (int)syscall (__NR_syncfs, (int)(fd));
#else
res = -1;
errno = ENOSYS;
res = EIO_ENOSYS ();
#endif
if (res < 0 && errno == ENOSYS && fd >= 0)
......@@ -1075,11 +1074,10 @@ eio__sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags)
static int
eio__fallocate (int fd, int mode, off_t offset, size_t len)
{
#if HAVE_FALLOCATE
#if HAVE_LINUX_FALLOCATE
return fallocate (fd, mode, offset, len);
#else
errno = ENOSYS;
return -1;
return EIO_ENOSYS ();
#endif
}
......@@ -1104,8 +1102,9 @@ eio__readahead (int fd, off_t offset, size_t count, etp_worker *self)
FUBd;
errno = 0;
return count;
/* linux's readahead basically only fails for EBADF or EINVAL (not mmappable) */
/* but not for e.g. EIO or eof, so we also never fail */
return 0;
}
#endif
......@@ -1150,7 +1149,7 @@ eio__sendfile (int ofd, int ifd, off_t offset, size_t count)
if (sbytes)
res = sbytes;
# elif defined (__APPLE__)
# elif defined __APPLE__
off_t sbytes = count;
res = sendfile (ifd, ofd, offset, &sbytes, 0, 0);
......@@ -1187,8 +1186,7 @@ eio__sendfile (int ofd, int ifd, off_t offset, size_t count)
res = TransmitFile (TO_SOCKET (ofd), h, count, 0, 0, 0, 0);
#else
res = -1;
errno = ENOSYS;
res = EIO_ENOSYS ();
#endif
/* we assume sendfile can copy at least 128mb in one go */
......@@ -1384,6 +1382,20 @@ eio__mtouch (eio_req *req)
/*****************************************************************************/
/* requests implemented outside eio_execute, because they are so large */
static void