From owner-p4-projects@FreeBSD.ORG Fri Aug 13 22:06:43 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4F1FB16A4D0; Fri, 13 Aug 2004 22:06:43 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 27F8D16A4CE for ; Fri, 13 Aug 2004 22:06:43 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0491743D1D for ; Fri, 13 Aug 2004 22:06:43 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i7DM6gsx006442 for ; Fri, 13 Aug 2004 22:06:42 GMT (envelope-from davidxu@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i7DM6gpM006439 for perforce@freebsd.org; Fri, 13 Aug 2004 22:06:42 GMT (envelope-from davidxu@freebsd.org) Date: Fri, 13 Aug 2004 22:06:42 GMT Message-Id: <200408132206.i7DM6gpM006439@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to davidxu@freebsd.org using -f From: David Xu To: Perforce Change Reviews Subject: PERFORCE change 59594 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2004 22:06:43 -0000 http://perforce.freebsd.org/chv.cgi?CH=59594 Change 59594 by davidxu@davidxu_alona on 2004/08/13 22:06:25 Call _set_curthread in _thread_start to set arch dependent environment for current thread, this is needed on AMD64. Affected files ... .. //depot/projects/davidxu_ksedbg/src/lib/libthr/thread/thr_create.c#5 edit .. //depot/projects/davidxu_ksedbg/src/lib/libthr/thread/thr_private.h#5 edit Differences ... ==== //depot/projects/davidxu_ksedbg/src/lib/libthr/thread/thr_create.c#5 (text+ko) ==== @@ -99,9 +99,10 @@ /* Initialise the machine context: */ getcontext(&new_thread->ctx); + new_thread->savedsig = new_thread->ctx.uc_sigmask; new_thread->ctx.uc_stack.ss_sp = new_thread->stack; new_thread->ctx.uc_stack.ss_size = pattr->stacksize_attr; - makecontext(&new_thread->ctx, _thread_start, 0); + makecontext(&new_thread->ctx, (void (*)(void))_thread_start, 1, new_thread); new_thread->arch_id = _set_curthread(&new_thread->ctx, new_thread, &ret); if (ret != 0) { if (pattr->stackaddr_attr == NULL) { @@ -145,7 +146,11 @@ */ if (pattr->suspend == PTHREAD_CREATE_SUSPENDED) new_thread->flags |= PTHREAD_FLAGS_SUSPENDED; + /* new thread inherits signal mask in kernel */ + _thread_sigblock(); ret = thr_create(&new_thread->ctx, &new_thread->thr_id, flags); + /* restore my signal mask */ + _thread_sigunblock(); if (ret != 0) { _thread_printf(STDERR_FILENO, "thr_create() == %d\n", ret); PANIC("thr_create"); @@ -160,10 +165,15 @@ } void -_thread_start(void) +_thread_start(pthread_t td) { + int ret; + + _set_curthread(NULL, td, &ret); + __sys_sigprocmask(SIG_SETMASK, &td->savedsig, NULL); if ((curthread->flags & PTHREAD_FLAGS_SUSPENDED) != 0) _thread_suspend(curthread, NULL); + pthread_exit(curthread->start_routine(curthread->arg)); /* This point should never be reached. */ ==== //depot/projects/davidxu_ksedbg/src/lib/libthr/thread/thr_private.h#5 (text+ko) ==== @@ -797,7 +797,7 @@ void _thread_dump_info(void); void _thread_init(void); void _thread_printf(int fd, const char *, ...); -void _thread_start(void); +void _thread_start(pthread_t); void _thread_seterrno(pthread_t, int); void _thread_enter_cancellation_point(void); void _thread_leave_cancellation_point(void);