This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 10/14] Consolidate non cancellable nanosleep call


Since this is a refactor, if no one opposes I will commit it shortly.

On 03/08/2017 10:11, Adhemerval Zanella wrote:
> This patch consolidates all the non cancellable nanosleep calls to use
> the __nanosleep_nocancel identifier.  For non cancellable targets it will
> be just a macro to call the default respective symbol while on Linux
> will be a internal one.
> 
> Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu.
> 
> 	* nptl/pthread_mutex_timedlock.c (__pthread_mutex_timedlock): Replace
> 	nanosleep_not_cancel with __nanosleep_nocancel.
> 	* sysdeps/generic/not-cancel.h (nanosleep_not_cancel): Remove macro.
> 	(__nanosleep_nocancel): New macro.
> 	* sysdeps/unix/sysv/linux/nanosleep.c (__nanosleep_nocancel): New
> 	function.
> 	* sysdeps/unix/sysv/linux/not-cancel.h (nanosleep_not_cancel): Remove
> 	macro.
> 	(__nanosleep_nocancel): New prototype.
> ---
>  ChangeLog                            | 10 ++++++++++
>  nptl/pthread_mutex_timedlock.c       |  2 +-
>  sysdeps/generic/not-cancel.h         |  2 +-
>  sysdeps/unix/sysv/linux/nanosleep.c  |  9 +++++++++
>  sysdeps/unix/sysv/linux/not-cancel.h |  5 +++--
>  5 files changed, 24 insertions(+), 4 deletions(-)
> 
> diff --git a/ChangeLog b/ChangeLog
> index 877c5d9..bf9bd57 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,5 +1,15 @@
>  2017-08-02  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
>  
> +	* nptl/pthread_mutex_timedlock.c (__pthread_mutex_timedlock): Replace
> +	nanosleep_not_cancel with __nanosleep_nocancel.
> +	* sysdeps/generic/not-cancel.h (nanosleep_not_cancel): Remove macro.
> +	(__nanosleep_nocancel): New macro.
> +	* sysdeps/unix/sysv/linux/nanosleep.c (__nanosleep_nocancel): New
> +	function.
> +	* sysdeps/unix/sysv/linux/not-cancel.h (nanosleep_not_cancel): Remove
> +	macro.
> +	(__nanosleep_nocancel): New prototype.
> +
>  	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Replace
>  	pause_not_cancel with __pause_nocancel.
>  	* sysdeps/generic/not-cancel.h (pause_not_cancel): Remove macro.
> diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
> index d5ec314..45f3454 100644
> --- a/nptl/pthread_mutex_timedlock.c
> +++ b/nptl/pthread_mutex_timedlock.c
> @@ -432,7 +432,7 @@ __pthread_mutex_timedlock (pthread_mutex_t *mutex,
>  			--reltime.tv_sec;
>  		      }
>  		    if (reltime.tv_sec >= 0)
> -		      while (nanosleep_not_cancel (&reltime, &reltime) != 0)
> +		      while (__nanosleep_nocancel (&reltime, &reltime) != 0)
>  			continue;
>  
>  		    return ETIMEDOUT;
> diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
> index f2140c2..e4a8584 100644
> --- a/sysdeps/generic/not-cancel.h
> +++ b/sysdeps/generic/not-cancel.h
> @@ -40,7 +40,7 @@
>    __waitpid (pid, stat_loc, options)
>  #define __pause_nocancel() \
>    __pause ()
> -#define nanosleep_not_cancel(requested_time, remaining) \
> +#define __nanosleep_nocancel(requested_time, remaining) \
>    __nanosleep (requested_time, remaining)
>  #define sigsuspend_not_cancel(set) \
>    __sigsuspend (set)
> diff --git a/sysdeps/unix/sysv/linux/nanosleep.c b/sysdeps/unix/sysv/linux/nanosleep.c
> index 2d15328..e7ac2c0 100644
> --- a/sysdeps/unix/sysv/linux/nanosleep.c
> +++ b/sysdeps/unix/sysv/linux/nanosleep.c
> @@ -18,6 +18,7 @@
>  
>  #include <time.h>
>  #include <sysdep-cancel.h>
> +#include <not-cancel.h>
>  
>  /* Pause execution for a number of nanoseconds.  */
>  int
> @@ -28,3 +29,11 @@ __nanosleep (const struct timespec *requested_time,
>  }
>  hidden_def (__nanosleep)
>  weak_alias (__nanosleep, nanosleep)
> +
> +int
> +__nanosleep_nocancel (const struct timespec *requested_time,
> +		      struct timespec *remaining)
> +{
> +  return INLINE_SYSCALL_CALL (nanosleep, requested_time, remaining);
> +}
> +hidden_def (__nanosleep_nocancel)
> diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
> index 89c1f46..07f07f6 100644
> --- a/sysdeps/unix/sysv/linux/not-cancel.h
> +++ b/sysdeps/unix/sysv/linux/not-cancel.h
> @@ -26,6 +26,7 @@
>  #include <unistd.h>
>  #include <sys/syscall.h>
>  #include <sys/wait.h>
> +#include <time.h>
>  
>  /* Non cancellable open syscall.  */
>  __typeof (open) __open_nocancel;
> @@ -82,8 +83,8 @@ __typeof (pause) __pause_nocancel;
>  libc_hidden_proto (__pause_nocancel)
>  
>  /* Uncancelable nanosleep.  */
> -#define nanosleep_not_cancel(requested_time, remaining) \
> -  INLINE_SYSCALL (nanosleep, 2, requested_time, remaining)
> +__typeof (__nanosleep) __nanosleep_nocancel;
> +hidden_proto (__nanosleep_nocancel)
>  
>  /* Uncancelable sigsuspend.  */
>  #define sigsuspend_not_cancel(set) \
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]