* [PATCH] Use *_not_cancel instead of __libc_* in linuxthreads
@ 2004-05-02 13:09 Jakub Jelinek
2004-05-03 21:42 ` Ulrich Drepper
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2004-05-02 13:09 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: Glibc hackers
Hi!
Probably it is not necessary in all places, but certainly in the past the
__libc_{read,write,close,waitpid} routines weren't a cancellation point
and if linuxthreads wanted to use cancellation point, it would just use
the non-__libc_ variants.
2004-05-02 Jakub Jelinek <jakub@redhat.com>
* manager.c: Include not-cancel.h.
(__pthread_manager): Use read_not_cancel instead of __libc_read.
(pthread_start_thread, __pthread_manager_sighandler): Use
write_not_cancel instead of __libc_write.
(pthread_reap_children): Use waitpid_not_cancel instead of
__libc_waitpid.
* pthread.c: Include not-cancel.h.
(__pthread_initialize_minimal, __pthread_create_2_1,
pthread_onexit_process, __pthread_message): Use
write_not_cancel instead of __libc_write.
(__pthread_initialize_manager): Likewise. Use close_not_cancel
instead of __libc_close.
(__pthread_reset_main_thread): Use close_not_cancel instead of
__libc_close.
* join.c: Include not-cancel.h.
(__pthread_do_exit, pthread_join, pthread_detach): Use
write_not_cancel instead of __libc_write.
* semaphore.c: Include not-cancel.h.
(__new_sem_post): Use write_not_cancel instead of __libc_write.
* specific.c: Include not-cancel.h.
(pthread_key_delete): Use write_not_cancel instead of __libc_write.
--- libc/linuxthreads/manager.c.jj 2004-05-02 12:56:45.000000000 +0200
+++ libc/linuxthreads/manager.c 2004-05-02 13:02:39.760579503 +0200
@@ -36,6 +36,7 @@
#include "spinlock.h"
#include "restart.h"
#include "semaphore.h"
+#include <not-cancel.h>
/* For debugging purposes put the maximum number of threads in a variable. */
const int __linuxthreads_pthread_threads_max = PTHREAD_THREADS_MAX;
@@ -141,8 +142,8 @@ __pthread_manager(void *arg)
/* Raise our priority to match that of main thread */
__pthread_manager_adjust_prio(__pthread_main_thread->p_priority);
/* Synchronize debugging of the thread manager */
- n = TEMP_FAILURE_RETRY(__libc_read(reqfd, (char *)&request,
- sizeof(request)));
+ n = TEMP_FAILURE_RETRY(read_not_cancel(reqfd, (char *)&request,
+ sizeof(request)));
ASSERT(n == sizeof(request) && request.req_kind == REQ_DEBUG);
ufd.fd = reqfd;
ufd.events = POLLIN;
@@ -162,8 +163,8 @@ __pthread_manager(void *arg)
}
/* Read and execute request */
if (n == 1 && (ufd.revents & POLLIN)) {
- n = TEMP_FAILURE_RETRY(__libc_read(reqfd, (char *)&request,
- sizeof(request)));
+ n = TEMP_FAILURE_RETRY(read_not_cancel(reqfd, (char *)&request,
+ sizeof(request)));
#ifdef DEBUG
if (n < 0) {
char d[64];
@@ -301,8 +302,8 @@ pthread_start_thread(void *arg)
if (__pthread_threads_debug && __pthread_sig_debug > 0) {
request.req_thread = self;
request.req_kind = REQ_DEBUG;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
- (char *) &request, sizeof(request)));
+ TEMP_FAILURE_RETRY(write_not_cancel(__pthread_manager_request,
+ (char *) &request, sizeof(request)));
suspend(self);
}
/* Run the thread code */
@@ -970,7 +971,7 @@ static void pthread_reap_children(void)
pid_t pid;
int status;
- while ((pid = __libc_waitpid(-1, &status, WNOHANG | __WCLONE)) > 0) {
+ while ((pid = waitpid_not_cancel(-1, &status, WNOHANG | __WCLONE)) > 0) {
pthread_exited(pid);
if (WIFSIGNALED(status)) {
/* If a thread died due to a signal, send the same signal to
@@ -1090,8 +1091,8 @@ void __pthread_manager_sighandler(int si
struct pthread_request request;
request.req_thread = 0;
request.req_kind = REQ_KICK;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
- (char *) &request, sizeof(request)));
+ TEMP_FAILURE_RETRY(write_not_cancel(__pthread_manager_request,
+ (char *) &request, sizeof(request)));
}
}
--- libc/linuxthreads/pthread.c.jj 2003-12-19 17:54:29.000000000 +0100
+++ libc/linuxthreads/pthread.c 2004-05-02 13:45:42.000000000 +0200
@@ -34,6 +34,7 @@
#include <ldsodefs.h>
#include <tls.h>
#include <version.h>
+#include <not-cancel.h>
/* Sanity check. */
#if !defined __SIGRTMIN || (__SIGRTMAX - __SIGRTMIN) < 3
@@ -328,8 +329,8 @@ __pthread_initialize_minimal(void)
{
static const char msg[] = "\
cannot allocate TLS data structures for initial thread\n";
- TEMP_FAILURE_RETRY (__libc_write (STDERR_FILENO,
- msg, sizeof msg - 1));
+ TEMP_FAILURE_RETRY (write_not_cancel (STDERR_FILENO,
+ msg, sizeof msg - 1));
abort ();
}
const char *lossage = TLS_INIT_TP (tcbp, 0);
@@ -337,11 +338,11 @@ cannot allocate TLS data structures for
{
static const char msg[] = "cannot set up thread-local storage: ";
const char nl = '\n';
- TEMP_FAILURE_RETRY (__libc_write (STDERR_FILENO,
- msg, sizeof msg - 1));
- TEMP_FAILURE_RETRY (__libc_write (STDERR_FILENO,
- lossage, strlen (lossage)));
- TEMP_FAILURE_RETRY (__libc_write (STDERR_FILENO, &nl, 1));
+ TEMP_FAILURE_RETRY (write_not_cancel (STDERR_FILENO,
+ msg, sizeof msg - 1));
+ TEMP_FAILURE_RETRY (write_not_cancel (STDERR_FILENO,
+ lossage, strlen (lossage)));
+ TEMP_FAILURE_RETRY (write_not_cancel (STDERR_FILENO, &nl, 1));
}
/* Though it was allocated with libc's malloc, that was done without
@@ -657,8 +658,8 @@ int __pthread_initialize_manager(void)
tcbp = _dl_allocate_tls (NULL);
if (tcbp == NULL) {
free(__pthread_manager_thread_bos);
- __libc_close(manager_pipe[0]);
- __libc_close(manager_pipe[1]);
+ close_not_cancel(manager_pipe[0]);
+ close_not_cancel(manager_pipe[1]);
return -1;
}
@@ -787,8 +788,8 @@ int __pthread_initialize_manager(void)
_dl_deallocate_tls (tcbp, true);
#endif
free(__pthread_manager_thread_bos);
- __libc_close(manager_pipe[0]);
- __libc_close(manager_pipe[1]);
+ close_not_cancel(manager_pipe[0]);
+ close_not_cancel(manager_pipe[1]);
return -1;
}
mgr->p_tid = 2* PTHREAD_THREADS_MAX + 1;
@@ -803,8 +804,8 @@ int __pthread_initialize_manager(void)
}
/* Synchronize debugging of the thread manager */
request.req_kind = REQ_DEBUG;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
- (char *) &request, sizeof(request)));
+ TEMP_FAILURE_RETRY(write_not_cancel(__pthread_manager_request,
+ (char *) &request, sizeof(request)));
return 0;
}
@@ -826,8 +827,8 @@ int __pthread_create_2_1(pthread_t *thre
request.req_args.create.arg = arg;
sigprocmask(SIG_SETMASK, (const sigset_t *) NULL,
&request.req_args.create.mask);
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
- (char *) &request, sizeof(request)));
+ TEMP_FAILURE_RETRY(write_not_cancel(__pthread_manager_request,
+ (char *) &request, sizeof(request)));
suspend(self);
retval = THREAD_GETMEM(self, p_retcode);
if (__builtin_expect (retval, 0) == 0)
@@ -1004,8 +1005,8 @@ static void pthread_onexit_process(int r
request.req_thread = self;
request.req_kind = REQ_PROCESS_EXIT;
request.req_args.exit.code = retcode;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
- (char *) &request, sizeof(request)));
+ TEMP_FAILURE_RETRY(write_not_cancel(__pthread_manager_request,
+ (char *) &request, sizeof(request)));
suspend(self);
/* Main thread should accumulate times for thread manager and its
children, so that timings for main thread account for all threads. */
@@ -1127,8 +1128,8 @@ void __pthread_reset_main_thread(void)
free(__pthread_manager_thread_bos);
__pthread_manager_thread_bos = __pthread_manager_thread_tos = NULL;
/* Close the two ends of the pipe */
- __libc_close(__pthread_manager_request);
- __libc_close(__pthread_manager_reader);
+ close_not_cancel(__pthread_manager_request);
+ close_not_cancel(__pthread_manager_reader);
__pthread_manager_request = __pthread_manager_reader = -1;
}
@@ -1399,7 +1400,7 @@ void __pthread_message(const char * fmt,
va_start(args, fmt);
vsnprintf(buffer + 8, sizeof(buffer) - 8, fmt, args);
va_end(args);
- TEMP_FAILURE_RETRY(__libc_write(2, buffer, strlen(buffer)));
+ TEMP_FAILURE_RETRY(write_not_cancel(2, buffer, strlen(buffer)));
}
#endif
--- libc/linuxthreads/join.c.jj 2004-05-02 12:56:31.000000000 +0200
+++ libc/linuxthreads/join.c 2004-05-02 14:06:45.263415328 +0200
@@ -22,6 +22,7 @@
#include "internals.h"
#include "spinlock.h"
#include "restart.h"
+#include <not-cancel.h>
void __pthread_exit(void * retval)
{
@@ -78,8 +79,8 @@ void __pthread_do_exit(void *retval, cha
if (self == __pthread_main_thread && __pthread_manager_request >= 0) {
request.req_thread = self;
request.req_kind = REQ_MAIN_THREAD_EXIT;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
- (char *)&request, sizeof(request)));
+ TEMP_FAILURE_RETRY(write_not_cancel(__pthread_manager_request,
+ (char *)&request, sizeof(request)));
suspend(self);
/* Main thread flushes stdio streams and runs atexit functions.
It also calls a handler within LinuxThreads which sends a process exit
@@ -174,8 +175,8 @@ int pthread_join(pthread_t thread_id, vo
request.req_thread = self;
request.req_kind = REQ_FREE;
request.req_args.free.thread_id = thread_id;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
- (char *) &request, sizeof(request)));
+ TEMP_FAILURE_RETRY(write_not_cancel(__pthread_manager_request,
+ (char *) &request, sizeof(request)));
}
return 0;
}
@@ -212,8 +213,8 @@ int pthread_detach(pthread_t thread_id)
request.req_thread = thread_self();
request.req_kind = REQ_FREE;
request.req_args.free.thread_id = thread_id;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
- (char *) &request, sizeof(request)));
+ TEMP_FAILURE_RETRY(write_not_cancel(__pthread_manager_request,
+ (char *) &request, sizeof(request)));
}
return 0;
}
--- libc/linuxthreads/semaphore.c.jj 2004-04-28 20:43:02.000000000 +0200
+++ libc/linuxthreads/semaphore.c 2004-05-02 13:46:11.000000000 +0200
@@ -22,6 +22,7 @@
#include "restart.h"
#include "queue.h"
#include <shlib-compat.h>
+#include <not-cancel.h>
int __new_sem_init(sem_t *sem, int pshared, unsigned int value)
{
@@ -168,8 +169,8 @@ int __new_sem_post(sem_t * sem)
}
request.req_kind = REQ_POST;
request.req_args.post = sem;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
- (char *) &request, sizeof(request)));
+ TEMP_FAILURE_RETRY(write_not_cancel(__pthread_manager_request,
+ (char *) &request, sizeof(request)));
}
return 0;
}
--- libc/linuxthreads/specific.c.jj 2003-02-20 00:59:44.000000000 +0100
+++ libc/linuxthreads/specific.c 2004-05-02 13:46:55.000000000 +0200
@@ -22,7 +22,7 @@
#include "spinlock.h"
#include "restart.h"
#include <bits/libc-lock.h>
-
+#include <not-cancel.h>
/* Table of keys. */
@@ -120,8 +120,8 @@ int pthread_key_delete(pthread_key_t key
request.req_args.for_each.arg = &args;
request.req_args.for_each.fn = pthread_key_delete_helper;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
- (char *) &request, sizeof(request)));
+ TEMP_FAILURE_RETRY(write_not_cancel(__pthread_manager_request,
+ (char *) &request, sizeof(request)));
suspend(self);
}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Use *_not_cancel instead of __libc_* in linuxthreads
2004-05-02 13:09 [PATCH] Use *_not_cancel instead of __libc_* in linuxthreads Jakub Jelinek
@ 2004-05-03 21:42 ` Ulrich Drepper
0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2004-05-03 21:42 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Glibc hackers
Applied.
--
⧠Ulrich Drepper ⧠Red Hat, Inc. ⧠444 Castro St ⧠Mountain View, CA â
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-05-03 21:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-02 13:09 [PATCH] Use *_not_cancel instead of __libc_* in linuxthreads Jakub Jelinek
2004-05-03 21:42 ` Ulrich Drepper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).