[PATCH] [BZ #18970]: Reference of pthread_setcancelstate in libc.a
H.J. Lu
hongjiu.lu@intel.com
Thu Sep 17 15:21:00 GMT 2015
This patch references __pthread_setcancelstate instead of
pthread_setcancelstate in libc.a. OK for master?
H.J.
---
[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): New. 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.
---
misc/error.c | 11 ++++++-----
nptl/forward.c | 5 +++--
nptl/nptl-init.c | 2 +-
nptl/pthreadP.h | 2 ++
nptl/pthread_setcancelstate.c | 1 +
posix/wordexp.c | 5 +++--
stdlib/fmtmsg.c | 6 +++---
sysdeps/nptl/libc-lockP.h | 5 +++--
sysdeps/nptl/pthread-functions.h | 2 +-
sysdeps/unix/sysv/linux/fatal-prepare.h | 19 +++----------------
10 files changed, 26 insertions(+), 32 deletions(-)
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..a90a415 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -491,6 +491,7 @@ extern int __pthread_setcanceltype (int type, int *oldtype);
extern int __pthread_enable_asynccancel (void) attribute_hidden;
extern void __pthread_disable_asynccancel (int oldtype)
internal_function attribute_hidden;
+extern int __pthread_setcancelstate (int state, int *oldstate);
#if IS_IN (libpthread)
hidden_proto (__pthread_mutex_init)
@@ -504,6 +505,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 <pthread-functions.h>
-# 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)
--
2.4.3
More information about the Libc-alpha
mailing list