Skip to content

Commit

Permalink
Use __pthread_setcancelstate in libc.a
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
H.J. Lu committed Sep 17, 2015
1 parent 61f8937 commit e5d19c0
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 33 deletions.
24 changes: 24 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
2015-09-17 H.J. Lu <hongjiu.lu@intel.com>

[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 <joseph@codesourcery.com>
Andreas Schwab <schwab@suse.de>

Expand Down
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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 <regexp.h> has been removed. Programs that require
this header must be updated to use <regex.h> instead.
Expand Down
11 changes: 6 additions & 5 deletions misc/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand All @@ -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
}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions nptl/forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion nptl/nptl-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions nptl/pthreadP.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions nptl/pthread_setcancelstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ __pthread_setcancelstate (state, oldstate)
return 0;
}
strong_alias (__pthread_setcancelstate, pthread_setcancelstate)
hidden_def (__pthread_setcancelstate)
5 changes: 3 additions & 2 deletions posix/wordexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1186,15 +1186,16 @@ 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

error = exec_comm (comm, word, word_length, 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);
Expand Down
6 changes: 3 additions & 3 deletions stdlib/fmtmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions sysdeps/nptl/libc-lockP.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion sysdeps/nptl/pthread-functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
19 changes: 3 additions & 16 deletions sysdeps/unix/sysv/linux/fatal-prepare.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit e5d19c0

Please sign in to comment.