[2/3] htl: Use __hurd_fail () instead of assigning errno

Message ID 20230520115531.3911877-2-bugaevc@gmail.com
State Committed
Commit 70d0dda0c160cb1f9000a4da50baf27c63db51c8
Headers
Series [1/3] hurd: Use __hurd_fail () instead of assigning errno |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_glibc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 fail Patch failed to apply

Commit Message

Sergey Bugaev May 20, 2023, 11:55 a.m. UTC
  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(-)
  

Comments

Samuel Thibault May 20, 2023, 4:15 p.m. UTC | #1
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
>
  

Patch

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);