htl: Add wrapper header for <semaphore.h> with hidden __sem_post

Message ID 87eeq4d7zp.fsf@oldenburg2.str.redhat.com
State New
Headers show
Series
  • htl: Add wrapper header for <semaphore.h> with hidden __sem_post
Related show

Commit Message

Ben Woodard via Libc-alpha June 24, 2020, 11:21 a.m.
This is required to avoid a check-localplt failure due to a
sem_post call through the PLT.

---
 sysdeps/htl/include/semaphore.h | 9 +++++++++
 sysdeps/htl/sem-post.c          | 2 +-
 sysdeps/htl/sem-timedwait.c     | 2 +-
 3 files changed, 11 insertions(+), 2 deletions(-)

Comments

Samuel Thibault June 24, 2020, 11:36 a.m. | #1
Florian Weimer, le mer. 24 juin 2020 13:21:46 +0200, a ecrit:
> This is required to avoid a check-localplt failure due to a

> sem_post call through the PLT.


Oh, sorry I didn't check that, thanks!

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>


> ---

>  sysdeps/htl/include/semaphore.h | 9 +++++++++

>  sysdeps/htl/sem-post.c          | 2 +-

>  sysdeps/htl/sem-timedwait.c     | 2 +-

>  3 files changed, 11 insertions(+), 2 deletions(-)

> 

> diff --git a/sysdeps/htl/include/semaphore.h b/sysdeps/htl/include/semaphore.h

> new file mode 100644

> index 0000000000..58fa2bf341

> --- /dev/null

> +++ b/sysdeps/htl/include/semaphore.h

> @@ -0,0 +1,9 @@

> +#ifndef	_SEMAPHORE_H

> +#include_next <semaphore.h>

> +

> +#ifndef _ISOMAC

> +extern __typeof (sem_post) __sem_post;

> +libpthread_hidden_proto (__sem_post)

> +#endif

> +

> +#endif

> diff --git a/sysdeps/htl/sem-post.c b/sysdeps/htl/sem-post.c

> index fd0c6338c6..720b73a059 100644

> --- a/sysdeps/htl/sem-post.c

> +++ b/sysdeps/htl/sem-post.c

> @@ -64,5 +64,5 @@ __sem_post (sem_t *sem)

>  

>    return 0;

>  }

> -

> +libpthread_hidden_def (__sem_post)

>  strong_alias (__sem_post, sem_post);

> diff --git a/sysdeps/htl/sem-timedwait.c b/sysdeps/htl/sem-timedwait.c

> index fffdf36467..5095d49b28 100644

> --- a/sysdeps/htl/sem-timedwait.c

> +++ b/sysdeps/htl/sem-timedwait.c

> @@ -167,7 +167,7 @@ out_locked:

>      {

>        if (ret == 0 && ctx.cancel_wake == 0)

>  	/* We were cancelled while waking up with a token, put it back.  */

> -	sem_post (sem);

> +	__sem_post (sem);

>  

>        __pthread_exit (PTHREAD_CANCELED);

>      }

>

Patch

diff --git a/sysdeps/htl/include/semaphore.h b/sysdeps/htl/include/semaphore.h
new file mode 100644
index 0000000000..58fa2bf341
--- /dev/null
+++ b/sysdeps/htl/include/semaphore.h
@@ -0,0 +1,9 @@ 
+#ifndef	_SEMAPHORE_H
+#include_next <semaphore.h>
+
+#ifndef _ISOMAC
+extern __typeof (sem_post) __sem_post;
+libpthread_hidden_proto (__sem_post)
+#endif
+
+#endif
diff --git a/sysdeps/htl/sem-post.c b/sysdeps/htl/sem-post.c
index fd0c6338c6..720b73a059 100644
--- a/sysdeps/htl/sem-post.c
+++ b/sysdeps/htl/sem-post.c
@@ -64,5 +64,5 @@  __sem_post (sem_t *sem)
 
   return 0;
 }
-
+libpthread_hidden_def (__sem_post)
 strong_alias (__sem_post, sem_post);
diff --git a/sysdeps/htl/sem-timedwait.c b/sysdeps/htl/sem-timedwait.c
index fffdf36467..5095d49b28 100644
--- a/sysdeps/htl/sem-timedwait.c
+++ b/sysdeps/htl/sem-timedwait.c
@@ -167,7 +167,7 @@  out_locked:
     {
       if (ret == 0 && ctx.cancel_wake == 0)
 	/* We were cancelled while waking up with a token, put it back.  */
-	sem_post (sem);
+	__sem_post (sem);
 
       __pthread_exit (PTHREAD_CANCELED);
     }