[PATCH] Posix asynchronous I/O support, part 3

Corinna Vinschen corinna-cygwin@cygwin.com
Wed Apr 4 09:15:00 GMT 2018


On Mar 28 22:32, Mark Geisert wrote:
> ---
>  winsup/cygwin/aio.cc | 580 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 580 insertions(+)
>  create mode 100644 winsup/cygwin/aio.cc

Only scanning for minor stuff for now:

> diff --git a/winsup/cygwin/aio.cc b/winsup/cygwin/aio.cc
> new file mode 100644
> index 000000000..01bf2e479
> --- /dev/null
> +++ b/winsup/cygwin/aio.cc
> @@ -0,0 +1,580 @@
> +/* aio.cc: Posix asynchronous i/o functions.
> +
> +This file is part of Cygwin.
> +
> +This software is a copyrighted work licensed under the terms of the
> +Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
> +details. */
> +
> +#undef AIODEBUG
> +
> +#include "winsup.h"
> +#include <aio.h>
> +#include <fcntl.h>
> +#include <semaphore.h>
> +#include <unistd.h>
> +
> +#ifdef __cplusplus
> +#define restrict /* meaningless in C++ */

Just use __restrict

> +extern "C" {
> +#endif
> +
> +static NO_COPY pid_t         mypid;
> +static NO_COPY sem_t         worksem;   /* indicates whether AIOs are queued */
> +static NO_COPY struct aiocb *worklisthd = NULL;  /* head of pending AIO list */
> +static NO_COPY struct aiocb *worklisttl = NULL;  /* tail of pending AIO list */

May I suggest to use the types and macros from sys/queue.h instead of
implementing queues all by yourself?  TAILQ might be what you're
looking for.

> +static NO_COPY CRITICAL_SECTION  workcrit;      /* lock for pending AIO list */
> +
> +#ifdef AIODEBUG
> +static void
> +showqueue ()
> +{
> +  /* critical section 'workcrit' is held on entry */
> +  struct aiocb *aio = worklisthd;
> +
> +  small_printf ("%p", aio);

Better use debug_printf here so the debug output is only generated
under strace

Otherwise the code looks pretty neat already.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20180404/dab2702e/attachment.sig>


More information about the Cygwin-patches mailing list