npth change required for Android

Hans-Christoph Steiner hans at guardianproject.info
Mon Dec 9 18:49:37 CET 2013


Looks good to me.  Luckily, Android didn't do the very aggravating fake
version of this function that is has for others, so configure doesn't detect
anything for pthread_atfork():

checking for pthread_tryjoin_np... no
checking for pthread_setname_np... yes
checking for pthread_getname_np... no
checking for pthread_mutex_timedlock... no
checking for pthread_rwlock_rdlock... yes
checking for pthread_rwlock_wrlock... yes
checking for pthread_rwlock_timedrdlock... yes
checking for pthread_rwlock_timedwrlock... yes
checking for pthread_rwlock_tryrdlock... yes
checking for pthread_rwlock_trywrlock... yes
checking for pthread_atfork... no

(For other unimplemented libc functions, Android's bionic libc includes a stub
function that just printfs a message, so ./configure correctly detects that
function's presense, but its a non-functional function).

.hc

On 12/08/2013 09:47 PM, NIIBE Yutaka wrote:
> For the issue 1576 (reported by Hans Christoph Steiner), I write
> a patch for Npth.
> 
> OK to commit?
> 
> 
> [0] https://bugs.g10code.com/gnupg/issue1576
> 
> --------------
> diff --git a/configure.ac b/configure.ac
> index bd650c7..2a0216f 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -256,6 +256,7 @@ if test "$have_w32_system" = no; then
>      AC_CHECK_FUNCS([pthread_rwlock_rdlock pthread_rwlock_wrlock])
>      AC_CHECK_FUNCS([pthread_rwlock_timedrdlock pthread_rwlock_timedwrlock])
>      AC_CHECK_FUNCS([pthread_rwlock_tryrdlock pthread_rwlock_trywrlock])
> +    AC_CHECK_FUNCS([pthread_atfork])
>    fi
>  fi
>  
> diff --git a/src/npth-sigev.c b/src/npth-sigev.c
> index aab977e..78e92ff 100644
> --- a/src/npth-sigev.c
> +++ b/src/npth-sigev.c
> @@ -126,12 +126,16 @@ npth_sigev_add (int signum)
>  }
>  
> 
> +#ifdef HAVE_PTHREAD_ATFORK
> +/* There is non-POSIX operating system where fork is not available to
> +   applications.  There, we have no pthread_atfork either.  In such a
> +   case, we don't call pthread_atfork.  */
>  static void
>  restore_sigmask_for_child_process (void)
>  {
>    pthread_sigmask (SIG_SETMASK, &sigev_unblock, NULL);
>  }
> -
> +#endif
>  
>  /* Finish the list of watched signals.  This starts to block them,
>     too.  */
> @@ -140,7 +144,9 @@ npth_sigev_fini (void)
>  {
>    /* Block the interesting signals.  */
>    pthread_sigmask (SIG_SETMASK, &sigev_block, NULL);
> +#ifdef HAVE_PTHREAD_ATFORK
>    pthread_atfork (NULL, NULL, restore_sigmask_for_child_process);
> +#endif
>  }
>  
> 

-- 
PGP fingerprint: 5E61 C878 0F86 295C E17D  8677 9F0F E587 374B BE81



More information about the Gnupg-devel mailing list