[patch] aio_*() posix compliance
Neal H. Walfield
neal@cs.uml.edu
Tue Jun 18 14:17:00 GMT 2002
Amos Waterland <apw@us.ibm.com> writes:
> I believe that glibc with this patch is fully compliant, with the
> possible exception of this issue: the standard says for lio_listio()
> (http://www.opengroup.org/onlinepubs/007904975/functions/lio_listio.html):
>
> The lio_listio() function shall fail if:
>
> [EAGAIN] The number of entries indicated by nent would cause the
> system-wide limit {AIO_MAX} to be exceeded.
>
> [EINVAL] The mode argument is not a proper value, or the value of
> nent was greater than {AIO_LISTIO_MAX}.
>
> Glibc does not seem to define AIO_MAX and AIO_LISTIO_MAX, and because of
> the way sysconf() conditionally compiles, it returns -1 for both (see
> below for test0024.c):
>
> % ./test0024
> + _POSIX_ASYNCHRONOUS_IO
> + _POSIX_ASYNC_IO
> - AIO_LISTIO_MAX
> - AIO_MAX
> (-1) _SC_AIO_LISTIO_MAX
> (-1) _SC_AIO_MAX
>
> The lio_listio() function does not check for nent exceeding the
> constants of concern. I know that there might be a simple answer to
> this, so I wanted to ask you all about it before I added definitions to
> unistd.h and patched lio_listio.c.
The simple answer is found in the standard itself. From the section
describing <limits.h>:
Runtime Invariant Values (Possibly Indeterminate)
A definition of one of the symbolic names in the following list
shall be omitted from <limits.h> on specific implementations where
the corresponding value is equal to or greater than the stated
minimum, but is unspecified.
This indetermination might depend on the amount of available
memory space on a specific instance of a specific
implementation. The actual value supported by a specific instance
shall be provided by the sysconf() function.
{AIO_LISTIO_MAX}
[AIO] [Option Start]
Maximum number of I/O operations in a single list I/O call
supported by the implementation.
Minimum Acceptable Value: {_POSIX_AIO_LISTIO_MAX} [Option End]
{AIO_MAX}
[AIO] [Option Start]
Maximum number of outstanding asynchronous I/O operations
supported by the implementation.
Minimum Acceptable Value: {_POSIX_AIO_MAX} [Option End]
> printf( "(%li) _SC_AIO_LISTIO_MAX\n", sysconf( _SC_AIO_LISTIO_MAX ) );
> printf( "(%li) _SC_AIO_MAX\n", sysconf( _SC_AIO_MAX ) );
This is also crap: the fact that these functions return -1 is
meaningless without more context. From the section on sysconf:
RETURN VALUE
If name is an invalid value, sysconf() shall return -1 and set
errno to indicate the error. If the variable corresponding to name
has no limit, sysconf() shall return -1 without changing the value
of errno. Note that indefinite limits do not imply infinite
limits; see <limits.h>.
Otherwise, sysconf() shall return the current variable value on
the system. The value returned shall not be more restrictive than
the corresponding value described to the application when it was
compiled with the implementation's <limits.h> or <unistd.h>. The
value shall not change during the lifetime of the calling process.
More information about the Libc-alpha
mailing list