poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] ios: re-use ID if possible


From: Jose E. Marchesi
Subject: Re: [PATCH] ios: re-use ID if possible
Date: Sun, 22 Jan 2023 15:27:15 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Hi Mohammad.
This is OK, but for master only after we branch maint/poke-3.

> 2023-01-22  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
>
>       * libpoke/ios.c (ios_close): Re-use the IOS ID if possible.
>       * testsuite/poke.pkl/ios-close-1.pk: New test.
>       * testsuite/poke.pkl/ios-close-2.pk: Likewise.
>       * testsuite/Makefile.am (EXTRA_DIST): Add new tests.
> ---
>  ChangeLog                         |  7 +++++++
>  libpoke/ios.c                     |  4 ++++
>  testsuite/Makefile.am             |  2 ++
>  testsuite/poke.pkl/ios-close-1.pk | 14 ++++++++++++++
>  testsuite/poke.pkl/ios-close-2.pk | 10 ++++++++++
>  5 files changed, 37 insertions(+)
>  create mode 100644 testsuite/poke.pkl/ios-close-1.pk
>  create mode 100644 testsuite/poke.pkl/ios-close-2.pk
>
> diff --git a/ChangeLog b/ChangeLog
> index 58f0df2c..dab1e05d 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,10 @@
> +2023-01-22  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
> +
> +     * libpoke/ios.c (ios_close): Re-use the IOS ID if possible.
> +     * testsuite/poke.pkl/ios-close-1.pk: New test.
> +     * testsuite/poke.pkl/ios-close-2.pk: Likewise.
> +     * testsuite/Makefile.am (EXTRA_DIST): Add new tests.
> +
>  2023-01-22  Jose E. Marchesi  <jemarch@gnu.org>
>  
>       * testsuite/poke.pkl/acons-20.pk: New test.
> diff --git a/libpoke/ios.c b/libpoke/ios.c
> index 8e10d3f8..078f8128 100644
> --- a/libpoke/ios.c
> +++ b/libpoke/ios.c
> @@ -241,6 +241,10 @@ ios_close (ios io)
>    if (io == cur_io)
>      cur_io = io_list;
>  
> +  /* Re-use the ID if this IOS was the most-recently opened IOS.  */
> +  if (ios_next_id == io->id + 1)
> +    --ios_next_id;
> +
>    free (io);
>  
>    return IOD_ERROR_TO_IOS_ERROR (ret);
> diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
> index f32046cd..0abbb446 100644
> --- a/testsuite/Makefile.am
> +++ b/testsuite/Makefile.am
> @@ -1665,6 +1665,8 @@ EXTRA_DIST = \
>    poke.pkl/iolist-2.pk \
>    poke.pkl/iolist-3.pk \
>    poke.pkl/iolist-4.pk \
> +  poke.pkl/ios-close-1.pk \
> +  poke.pkl/ios-close-2.pk \
>    poke.pkl/iosetbias-1.pk \
>    poke.pkl/iosetbias-2.pk \
>    poke.pkl/iosetbias-3.pk \
> diff --git a/testsuite/poke.pkl/ios-close-1.pk 
> b/testsuite/poke.pkl/ios-close-1.pk
> new file mode 100644
> index 00000000..4682eae0
> --- /dev/null
> +++ b/testsuite/poke.pkl/ios-close-1.pk
> @@ -0,0 +1,14 @@
> +/* { dg-do run } */
> +
> +/* { dg-command { .set obase 10 } } */
> +/* { dg-command { open ("*1*") } } */
> +/* { dg-output "0\n" } */
> +/* { dg-command { open ("*2*") } } */
> +/* { dg-output "1\n" } */
> +/* { dg-command { close (1) } } */
> +/* { dg-command { open ("*3*") } } */
> +/* { dg-output "1\n" } */
> +/* { dg-command { close (1) } } */
> +/* { dg-command { close (0) } } */
> +/* { dg-command { open ("*3*") } } */
> +/* { dg-output "0\n" } */
> diff --git a/testsuite/poke.pkl/ios-close-2.pk 
> b/testsuite/poke.pkl/ios-close-2.pk
> new file mode 100644
> index 00000000..24ff2392
> --- /dev/null
> +++ b/testsuite/poke.pkl/ios-close-2.pk
> @@ -0,0 +1,10 @@
> +/* { dg-do run } */
> +
> +/* { dg-command { .set obase 10 } } */
> +/* { dg-command { open ("*1*") } } */
> +/* { dg-output "0\n" } */
> +/* { dg-command { open ("*2*") } } */
> +/* { dg-output "1\n" } */
> +/* { dg-command { close (0) } } */
> +/* { dg-command { open ("*3*") } } */
> +/* { dg-output "2\n" } */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]