From: H.J. Lu Date: Thu, 17 Sep 2015 23:38:54 +0000 (-0700) Subject: Use __pthread_setcancelstate in libc.a X-Git-Tag: upstream/2.24~1048 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e5d19c08d12880edbdf8772c8fb1f747c71d866e;p=platform%2Fupstream%2Fglibc.git Use __pthread_setcancelstate in libc.a This patch references __pthread_setcancelstate instead of pthread_setcancelstate in libc.a. [BZ #18970] * misc/error.c (error): Replace pthread_setcancelstate with __pthread_setcancelstate. (error_at_line): Likewise. * posix/wordexp.c (parse_comm): Likewise. * stdlib/fmtmsg.c (fmtmsg): Likewise. * nptl/forward.c (pthread_setcancelstate): Renamed to ... (__pthread_setcancelstate): This. (pthread_setcancelstate): Add an alias. * nptl/nptl-init.c (pthread_functions): Replace ptr_pthread_setcancelstate with ptr___pthread_setcancelstate. * sysdeps/nptl/pthread-functions.h (pthread_functions): Likewise. * nptl/pthreadP.h (__pthread_setcancelstate): Mark it with hidden_proto. * nptl/pthread_setcancelstate.c (__pthread_setcancelstate): Mark it with hidden_def. * sysdeps/nptl/libc-lockP.h (__pthread_setcancelstate): New. (pthread_setcancelstate): Renamed to ... (__pthread_setcancelstate): This. * sysdeps/unix/sysv/linux/fatal-prepare.h (FATAL_PREPARE): Use __libc_ptf_call with __pthread_setcancelstate. --- diff --git a/ChangeLog b/ChangeLog index 4de1a56..dd01ca1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2015-09-17 H.J. Lu + + [BZ #18970] + * misc/error.c (error): Replace pthread_setcancelstate with + __pthread_setcancelstate. + (error_at_line): Likewise. + * posix/wordexp.c (parse_comm): Likewise. + * stdlib/fmtmsg.c (fmtmsg): Likewise. + * nptl/forward.c (pthread_setcancelstate): Renamed to ... + (__pthread_setcancelstate): This. + (pthread_setcancelstate): Add an alias. + * nptl/nptl-init.c (pthread_functions): Replace + ptr_pthread_setcancelstate with ptr___pthread_setcancelstate. + * sysdeps/nptl/pthread-functions.h (pthread_functions): Likewise. + * nptl/pthreadP.h (__pthread_setcancelstate): Mark it with + hidden_proto. + * nptl/pthread_setcancelstate.c (__pthread_setcancelstate): Mark + it with hidden_def. + * sysdeps/nptl/libc-lockP.h (__pthread_setcancelstate): New. + (pthread_setcancelstate): Renamed to ... + (__pthread_setcancelstate): This. + * sysdeps/unix/sysv/linux/fatal-prepare.h (FATAL_PREPARE): Use + __libc_ptf_call with __pthread_setcancelstate. + 2015-09-17 Joseph Myers Andreas Schwab diff --git a/NEWS b/NEWS index d978701..e5a4629 100644 --- a/NEWS +++ b/NEWS @@ -15,7 +15,7 @@ Version 2.23 18421, 18480, 18525, 18595, 18610, 18618, 18647, 18661, 18674, 18675, 18681, 18757, 18778, 18781, 18787, 18789, 18790, 18795, 18796, 18820, 18823, 18824, 18857, 18863, 18870, 18872, 18873, 18875, 18887, 18921, - 18951, 18952, 18961, 18966, 18967, 18977. + 18951, 18952, 18961, 18966, 18967, 18970, 18977 * The obsolete header has been removed. Programs that require this header must be updated to use instead. diff --git a/misc/error.c b/misc/error.c index aa3054d..023e391 100644 --- a/misc/error.c +++ b/misc/error.c @@ -298,8 +298,8 @@ error (int status, int errnum, const char *message, ...) /* We do not want this call to be cut short by a thread cancellation. Therefore disable cancellation for now. */ int state = PTHREAD_CANCEL_ENABLE; - __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), - 0); + __libc_ptf_call (__pthread_setcancelstate, + (PTHREAD_CANCEL_DISABLE, &state), 0); #endif flush_stdout (); @@ -323,7 +323,7 @@ error (int status, int errnum, const char *message, ...) #ifdef _LIBC _IO_funlockfile (stderr); # ifdef __libc_ptf_call - __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); + __libc_ptf_call (__pthread_setcancelstate, (state, NULL), 0); # endif #endif } @@ -360,7 +360,8 @@ error_at_line (int status, int errnum, const char *file_name, /* We do not want this call to be cut short by a thread cancellation. Therefore disable cancellation for now. */ int state = PTHREAD_CANCEL_ENABLE; - __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), + __libc_ptf_call (__pthread_setcancelstate, + (PTHREAD_CANCEL_DISABLE, &state), 0); #endif @@ -393,7 +394,7 @@ error_at_line (int status, int errnum, const char *file_name, #ifdef _LIBC _IO_funlockfile (stderr); # ifdef __libc_ptf_call - __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); + __libc_ptf_call (__pthread_setcancelstate, (state, NULL), 0); # endif #endif } diff --git a/nptl/forward.c b/nptl/forward.c index db74f8d..57a12a4 100644 --- a/nptl/forward.c +++ b/nptl/forward.c @@ -197,8 +197,9 @@ FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0) FORWARD2 (pthread_self, pthread_t, (void), (), return 0) -FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate), - 0) +FORWARD (__pthread_setcancelstate, (int state, int *oldstate), + (state, oldstate), 0) +strong_alias (__pthread_setcancelstate, pthread_setcancelstate) FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0) diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index c043fb5..79bcaab 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -127,7 +127,7 @@ static const struct pthread_functions pthread_functions = .ptr_pthread_mutex_lock = __pthread_mutex_lock, .ptr_pthread_mutex_unlock = __pthread_mutex_unlock, .ptr_pthread_self = __pthread_self, - .ptr_pthread_setcancelstate = __pthread_setcancelstate, + .ptr___pthread_setcancelstate = __pthread_setcancelstate, .ptr_pthread_setcanceltype = __pthread_setcanceltype, .ptr___pthread_cleanup_upto = __pthread_cleanup_upto, .ptr___pthread_once = __pthread_once, diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 8cd51c6..b96be56 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -504,6 +504,7 @@ hidden_proto (__pthread_key_create) hidden_proto (__pthread_getspecific) hidden_proto (__pthread_setspecific) hidden_proto (__pthread_once) +hidden_proto (__pthread_setcancelstate) #endif extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond); diff --git a/nptl/pthread_setcancelstate.c b/nptl/pthread_setcancelstate.c index 1807789..c8bc8b8 100644 --- a/nptl/pthread_setcancelstate.c +++ b/nptl/pthread_setcancelstate.c @@ -70,3 +70,4 @@ __pthread_setcancelstate (state, oldstate) return 0; } strong_alias (__pthread_setcancelstate, pthread_setcancelstate) +hidden_def (__pthread_setcancelstate) diff --git a/posix/wordexp.c b/posix/wordexp.c index 49ab71d..a36d2f9 100644 --- a/posix/wordexp.c +++ b/posix/wordexp.c @@ -1186,7 +1186,7 @@ parse_comm (char **word, size_t *word_length, size_t *max_length, // XXX Ideally we do want the thread being cancelable. // XXX If demand is there we'll change it. int state = PTHREAD_CANCEL_ENABLE; - __libc_ptf_call (pthread_setcancelstate, + __libc_ptf_call (__pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), 0); #endif @@ -1194,7 +1194,8 @@ parse_comm (char **word, size_t *word_length, size_t *max_length, flags, pwordexp, ifs, ifs_white); #ifdef __libc_ptf_call - __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); + __libc_ptf_call (__pthread_setcancelstate, + (state, NULL), 0); #endif free (comm); diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c index a7abcbb..7b62c4e 100644 --- a/stdlib/fmtmsg.c +++ b/stdlib/fmtmsg.c @@ -127,8 +127,8 @@ fmtmsg (long int classification, const char *label, int severity, /* We do not want this call to be cut short by a thread cancellation. Therefore disable cancellation for now. */ int state = PTHREAD_CANCEL_ENABLE; - __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), - 0); + __libc_ptf_call (__pthread_setcancelstate, + (PTHREAD_CANCEL_DISABLE, &state), 0); #endif __libc_lock_lock (lock); @@ -199,7 +199,7 @@ fmtmsg (long int classification, const char *label, int severity, __libc_lock_unlock (lock); #ifdef __libc_ptf_call - __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); + __libc_ptf_call (__pthread_setcancelstate, (state, NULL), 0); #endif return result; diff --git a/sysdeps/nptl/libc-lockP.h b/sysdeps/nptl/libc-lockP.h index a64daca..29494fd 100644 --- a/sysdeps/nptl/libc-lockP.h +++ b/sysdeps/nptl/libc-lockP.h @@ -376,6 +376,7 @@ extern int __pthread_atfork (void (*__prepare) (void), void (*__parent) (void), void (*__child) (void)); +extern int __pthread_setcancelstate (int state, int *oldstate); /* Make the pthread functions weak so that we can elide them from @@ -403,9 +404,9 @@ weak_extern (__pthread_getspecific) weak_extern (__pthread_once) weak_extern (__pthread_initialize) weak_extern (__pthread_atfork) +weak_extern (__pthread_setcancelstate) weak_extern (_pthread_cleanup_push_defer) weak_extern (_pthread_cleanup_pop_restore) -weak_extern (pthread_setcancelstate) # else # pragma weak __pthread_mutex_init # pragma weak __pthread_mutex_destroy @@ -427,9 +428,9 @@ weak_extern (pthread_setcancelstate) # pragma weak __pthread_once # pragma weak __pthread_initialize # pragma weak __pthread_atfork +# pragma weak __pthread_setcancelstate # pragma weak _pthread_cleanup_push_defer # pragma weak _pthread_cleanup_pop_restore -# pragma weak pthread_setcancelstate # endif #endif diff --git a/sysdeps/nptl/pthread-functions.h b/sysdeps/nptl/pthread-functions.h index 0784c59..f37e9fd 100644 --- a/sysdeps/nptl/pthread-functions.h +++ b/sysdeps/nptl/pthread-functions.h @@ -75,7 +75,7 @@ struct pthread_functions int (*ptr_pthread_mutex_lock) (pthread_mutex_t *); int (*ptr_pthread_mutex_unlock) (pthread_mutex_t *); pthread_t (*ptr_pthread_self) (void); - int (*ptr_pthread_setcancelstate) (int, int *); + int (*ptr___pthread_setcancelstate) (int, int *); int (*ptr_pthread_setcanceltype) (int, int *); void (*ptr___pthread_cleanup_upto) (__jmp_buf, char *); int (*ptr___pthread_once) (pthread_once_t *, void (*) (void)); diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/sysdeps/unix/sysv/linux/fatal-prepare.h index 45d88ce..2a89567 100644 --- a/sysdeps/unix/sysv/linux/fatal-prepare.h +++ b/sysdeps/unix/sysv/linux/fatal-prepare.h @@ -19,19 +19,6 @@ /* We have to completely disable cancellation. assert() must not be a cancellation point but the implementation uses write() etc. */ -#ifdef SHARED -# include -# define FATAL_PREPARE \ - { \ - if (__libc_pthread_functions_init) \ - PTHFCT_CALL (ptr_pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, \ - NULL)); \ - } -#else -# pragma weak pthread_setcancelstate -# define FATAL_PREPARE \ - { \ - if (pthread_setcancelstate != NULL) \ - pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL); \ - } -#endif +#define FATAL_PREPARE \ + __libc_ptf_call (__pthread_setcancelstate, \ + (PTHREAD_CANCEL_DISABLE, NULL), 0)