From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: [PATCH 05/10] make thread_state into a real lisp object Date: Thu, 09 Aug 2012 13:41:03 -0600 Message-ID: <87ehnfetv4.fsf@fleche.redhat.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1344541276 12965 80.91.229.3 (9 Aug 2012 19:41:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Aug 2012 19:41:16 +0000 (UTC) To: Emacs discussions Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 09 21:41:16 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SzYbZ-0008M9-VO for ged-emacs-devel@m.gmane.org; Thu, 09 Aug 2012 21:41:14 +0200 Original-Received: from localhost ([::1]:48834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzYbZ-0002Qb-7A for ged-emacs-devel@m.gmane.org; Thu, 09 Aug 2012 15:41:13 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:46608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzYbW-0002QG-9I for emacs-devel@gnu.org; Thu, 09 Aug 2012 15:41:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzYbR-0004cR-NS for emacs-devel@gnu.org; Thu, 09 Aug 2012 15:41:10 -0400 Original-Received: from mx1.redhat.com ([209.132.183.28]:49681) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzYbR-0004cD-Ev for emacs-devel@gnu.org; Thu, 09 Aug 2012 15:41:05 -0400 Original-Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q79Jf4QA020011 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 9 Aug 2012 15:41:04 -0400 Original-Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q79Jf3AP007334 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 9 Aug 2012 15:41:03 -0400 X-Attribution: Tom User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:152379 Archived-At: This turns thread_state into a pseudovector and updates various bits of Emacs to cope. I don't think this patch will actually compile without a later patch as well. I haven't really been trying that, the patch splitting is really just to make them easier to reason about. In particular, this code refers to the thread's name, but that field isn't added yet. I can fix this up if you want each patch to build properly. --- src/emacs.c | 1 + src/lisp.h | 3 +++ src/print.c | 12 ++++++++++++ src/thread.c | 22 +++++++++++++++++++--- src/thread.h | 3 +++ 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/emacs.c b/src/emacs.c index 443fe59..ca9f201 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1226,6 +1226,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem if (!initialized) { init_alloc_once (); + init_threads_once (); init_obarray (); init_eval_once (); init_charset_once (); diff --git a/src/lisp.h b/src/lisp.h index fbde5bb..7d0a3dc 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -364,6 +364,7 @@ enum pvec_type PVEC_WINDOW_CONFIGURATION, PVEC_SUBR, PVEC_OTHER, + PVEC_THREAD, /* These last 4 are special because we OR them in fns.c:internal_equal, so they have to use a disjoint bit pattern: if (!(size & (PVEC_COMPILED | PVEC_CHAR_TABLE @@ -602,6 +603,7 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) #define XSETCHAR_TABLE(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_CHAR_TABLE)) #define XSETBOOL_VECTOR(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_BOOL_VECTOR)) #define XSETSUB_CHAR_TABLE(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_SUB_CHAR_TABLE)) +#define XSETTHREAD(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_THREAD)) /* Convenience macros for dealing with Lisp arrays. */ @@ -1700,6 +1702,7 @@ typedef struct { #define SUB_CHAR_TABLE_P(x) PSEUDOVECTORP (x, PVEC_SUB_CHAR_TABLE) #define BOOL_VECTOR_P(x) PSEUDOVECTORP (x, PVEC_BOOL_VECTOR) #define FRAMEP(x) PSEUDOVECTORP (x, PVEC_FRAME) +#define THREADP(x) PSEUDOVECTORP (x, PVEC_THREAD) /* Test for image (image . spec) */ #define IMAGEP(x) (CONSP (x) && EQ (XCAR (x), Qimage)) diff --git a/src/print.c b/src/print.c index 718e6a9..d879239 100644 --- a/src/print.c +++ b/src/print.c @@ -1943,6 +1943,18 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag } PRINTCHAR ('>'); } + else if (THREADP (obj)) + { + strout ("#name)) + print_string (XTHREAD (obj)->name, printcharfun); + else + { + int len = sprintf (buf, "%p", XTHREAD (obj)); + strout (buf, len, len, printcharfun); + } + PRINTCHAR ('>'); + } else { ptrdiff_t size = ASIZE (obj); diff --git a/src/thread.c b/src/thread.c index 605a52c..7d2f81e 100644 --- a/src/thread.c +++ b/src/thread.c @@ -32,7 +32,7 @@ sys_mutex_t global_lock; static void mark_one_thread (struct thread_state *thread) { - register struct specbinding *bind; + struct specbinding *bind; struct handler *handler; Lisp_Object tem; @@ -48,7 +48,7 @@ mark_one_thread (struct thread_state *thread) mark_stack (thread->m_stack_bottom, thread->stack_top); #else { - register struct gcpro *tail; + struct gcpro *tail; for (tail = thread->m_gcprolist; tail; tail = tail->next) for (i = 0; i < tail->nvars; i++) mark_object (tail->var[i]); @@ -88,7 +88,13 @@ mark_threads_callback (void *ignore) struct thread_state *iter; for (iter = all_threads; iter; iter = iter->next_thread) - mark_one_thread (iter); + { + Lisp_Object thread_obj; + + XSETTHREAD (thread_obj, iter); + mark_object (thread_obj); + mark_one_thread (iter); + } } void @@ -108,6 +114,16 @@ unmark_threads (void) } void +init_threads_once (void) +{ + the_only_thread.header.size + = PSEUDOVECSIZE (struct thread_state, m_gcprolist); + XSETPVECTYPE (&the_only_thread, PVEC_THREAD); + the_only_thread.m_last_thing_searched = Qnil; + the_only_thread.m_saved_last_thing_searched = Qnil; +} + +void init_threads (void) { sys_mutex_init (&global_lock); diff --git a/src/thread.h b/src/thread.h index def05fd..df26b88 100644 --- a/src/thread.h +++ b/src/thread.h @@ -23,6 +23,8 @@ along with GNU Emacs. If not, see . */ struct thread_state { + struct vectorlike_header header; + /* The buffer in which the last search was performed, or Qt if the last search was done in a string; Qnil if no searching has been done yet. */ @@ -150,6 +152,7 @@ extern sys_mutex_t global_lock; extern void unmark_threads (void); +extern void init_threads_once (void); extern void init_threads (void); #endif /* THREAD_H */ -- 1.7.7.6