]> git.eshelyaron.com Git - emacs.git/commitdiff
This turns thread_state into a pseudovector and updates various bits
authorTom Tromey <tromey@redhat.com>
Wed, 15 Aug 2012 19:07:04 +0000 (13:07 -0600)
committerTom Tromey <tromey@redhat.com>
Wed, 15 Aug 2012 19:07:04 +0000 (13:07 -0600)
of Emacs to cope.

src/emacs.c
src/lisp.h
src/print.c
src/thread.c
src/thread.h

index 443fe594795f0df5ffe36c7eb564601c5e30c952..ca9f201e8f52f3022230735245a5570eb0595ecd 100644 (file)
@@ -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 ();
index cbb5b51c783ca1f0a8eb40658989fe03e701ed40..2b3d40d3b2921cd09e9cc7c8c590d40c2146dbc2 100644 (file)
@@ -365,6 +365,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
@@ -603,6 +604,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.  */
 
@@ -1701,6 +1703,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))
index 23ad6c0a25659db34e676846aa6ce3256404db91..4537521b9faa9594dea85185545f80f0dc4735b6 100644 (file)
@@ -1943,6 +1943,18 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
            }
          PRINTCHAR ('>');
        }
+      else if (THREADP (obj))
+       {
+         strout ("#<thread ", -1, -1, printcharfun);
+         if (STRINGP (XTHREAD (obj)->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);
index 605a52cb2f99f03bd5290ef9bd4e501f08fc4063..7d2f81ec9ce1b8ef1e940f10a802650484907322 100644 (file)
@@ -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
@@ -107,6 +113,16 @@ unmark_threads (void)
       unmark_byte_stack (iter->m_byte_stack_list);
 }
 
+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)
 {
index def05fdaec992c1df8c4cc5dbbecbddfc0637227..df26b887d1f286ec96f348b40e0c7470c38997f0 100644 (file)
@@ -23,6 +23,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 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 */