public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@gnu.org>
To: Sergey Bugaev <bugaevc@gmail.com>
Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org
Subject: Re: [PATCH 2/3] htl: Use __hurd_fail () instead of assigning errno
Date: Sat, 20 May 2023 18:15:33 +0200	[thread overview]
Message-ID: <20230520161533.okfzmxiq4waqttuf@begin> (raw)
In-Reply-To: <20230520115531.3911877-2-bugaevc@gmail.com>

Applied, thanks!

Sergey Bugaev via Libc-alpha, le sam. 20 mai 2023 14:55:30 +0300, a ecrit:
> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
> ---
> 
> *Technically*, sysdeps/htl/ is not Hurd-specific (unlike, say,
> sysdeps/hurd/htl), but I don't think this distinction is meaningful,
> and the H in HTL must stand for something. Still, this is in a separate
> patch so it can be (not) applied easily.
> 
>  sysdeps/htl/sem-destroy.c |  6 ++----
>  sysdeps/htl/sem-init.c    |  6 ++----
>  sysdeps/htl/sem-post.c    | 11 +++--------
>  sysdeps/htl/sem-trywait.c |  4 ++--
>  4 files changed, 9 insertions(+), 18 deletions(-)
> 
> diff --git a/sysdeps/htl/sem-destroy.c b/sysdeps/htl/sem-destroy.c
> index 3e40151b..84a35ed5 100644
> --- a/sysdeps/htl/sem-destroy.c
> +++ b/sysdeps/htl/sem-destroy.c
> @@ -19,6 +19,7 @@
>  #include <semaphore.h>
>  #include <errno.h>
>  
> +#include <hurd.h>
>  #include <pt-internal.h>
>  
>  int
> @@ -34,10 +35,7 @@ __sem_destroy (sem_t *sem)
>  #endif
>        )
>      /* There are threads waiting on *SEM.  */
> -    {
> -      errno = EBUSY;
> -      return -1;
> -    }
> +    return __hurd_fail (EBUSY);
>  
>    return 0;
>  }
> diff --git a/sysdeps/htl/sem-init.c b/sysdeps/htl/sem-init.c
> index f04bbfdc..f2954acd 100644
> --- a/sysdeps/htl/sem-init.c
> +++ b/sysdeps/htl/sem-init.c
> @@ -19,6 +19,7 @@
>  #include <semaphore.h>
>  #include <errno.h>
>  
> +#include <hurd.h>
>  #include <pt-internal.h>
>  
>  int
> @@ -26,10 +27,7 @@ __sem_init (sem_t *sem, int pshared, unsigned value)
>  {
>  #ifdef SEM_VALUE_MAX
>    if (value > SEM_VALUE_MAX)
> -    {
> -      errno = EINVAL;
> -      return -1;
> -    }
> +    return __hurd_fail (EINVAL);
>  #endif
>  
>    struct new_sem *isem = (struct new_sem *) sem;
> diff --git a/sysdeps/htl/sem-post.c b/sysdeps/htl/sem-post.c
> index e283161a..c57458c1 100644
> --- a/sysdeps/htl/sem-post.c
> +++ b/sysdeps/htl/sem-post.c
> @@ -20,6 +20,7 @@
>  #include <assert.h>
>  
>  #include <hurdlock.h>
> +#include <hurd.h>
>  
>  #include <pt-internal.h>
>  
> @@ -35,10 +36,7 @@ __sem_post (sem_t *sem)
>    do
>      {
>        if ((d & SEM_VALUE_MASK) == SEM_VALUE_MAX)
> -	{
> -	  errno = EOVERFLOW;
> -	  return -1;
> -	}
> +	return __hurd_fail (EOVERFLOW);
>      }
>    while (!atomic_compare_exchange_weak_release (&isem->data, &d, d + 1));
>  
> @@ -51,10 +49,7 @@ __sem_post (sem_t *sem)
>    do
>      {
>        if ((v >> SEM_VALUE_SHIFT) == SEM_VALUE_MAX)
> -	{
> -	  errno = EOVERFLOW;
> -	  return -1;
> -	}
> +	return __hurd_fail (EOVERFLOW);
>      }
>    while (!atomic_compare_exchange_weak_release
>  	  (&isem->value, &v, v + (1 << SEM_VALUE_SHIFT)));
> diff --git a/sysdeps/htl/sem-trywait.c b/sysdeps/htl/sem-trywait.c
> index 0959092e..43aa185c 100644
> --- a/sysdeps/htl/sem-trywait.c
> +++ b/sysdeps/htl/sem-trywait.c
> @@ -19,6 +19,7 @@
>  #include <semaphore.h>
>  #include <errno.h>
>  
> +#include <hurd.h>
>  #include <pt-internal.h>
>  
>  int
> @@ -29,8 +30,7 @@ __sem_trywait (sem_t *sem)
>    if (__sem_waitfast (isem, 1) == 0)
>      return 0;
>  
> -  errno = EAGAIN;
> -  return -1;
> +  return __hurd_fail (EAGAIN);
>  }
>  
>  weak_alias (__sem_trywait, sem_trywait);
> -- 
> 2.40.1
> 

-- 
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.

  reply	other threads:[~2023-05-20 16:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-20 11:55 [PATCH 1/3] hurd: " Sergey Bugaev
2023-05-20 11:55 ` [PATCH 2/3] htl: " Sergey Bugaev
2023-05-20 16:15   ` Samuel Thibault [this message]
2023-05-20 11:55 ` [PATCH 3/3] io: Fix a typo Sergey Bugaev
2023-05-20 16:15   ` Samuel Thibault
2023-05-20 16:15 ` [PATCH 1/3] hurd: Use __hurd_fail () instead of assigning errno Samuel Thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230520161533.okfzmxiq4waqttuf@begin \
    --to=samuel.thibault@gnu.org \
    --cc=bug-hurd@gnu.org \
    --cc=bugaevc@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).