[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cygwin-patches
Subject:    Re: [PATCH] Posix asynchronous I/O support, part 3
From:       Corinna Vinschen <corinna-cygwin () cygwin ! com>
Date:       2018-04-04 9:15:41
Message-ID: 20180404091541.GL2833 () calimero ! vinschen ! de
[Download RAW message or body]


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

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic