From 41c8df9678f037d9fcefe68be6ba3008a639a4b2 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 6 Oct 2009 03:08:08 +0200 Subject: [PATCH] Initialize threads properly. Revert a few BUF_ changes to use direct field access. --- src/buffer.c | 16 ++++++++-------- src/emacs.c | 1 + src/marker.c | 2 +- src/thread.c | 10 ++++++++++ src/thread.h | 2 ++ 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index e144a8bfaf2..939d28e6210 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -391,7 +391,7 @@ even if it is dead. The return value is never nil. */) b->newline_cache = 0; b->width_run_cache = 0; - BUF_WIDTH_TABLE (b) = Qnil; +b->width_table_ = Qnil; b->prevent_redisplay_optimizations_p = 1; /* Put this on the chain of all buffers including killed ones. */ @@ -400,22 +400,22 @@ even if it is dead. The return value is never nil. */) /* An ordinary buffer normally doesn't need markers to handle BEGV and ZV. */ - BUF_PT_MARKER (b) = Qnil; - BUF_BEGV_MARKER (b) = Qnil; - BUF_ZV_MARKER (b) = Qnil; + b->pt_marker_ = Qnil; + b->begv_marker_ = Qnil; + b->zv_marker_ = Qnil; name = Fcopy_sequence (buffer_or_name); STRING_SET_INTERVALS (name, NULL_INTERVAL); - BUF_NAME (b) = name; + b->name_ = name; - BUF_UNDO_LIST (b) = (SREF (name, 0) != ' ') ? Qnil : Qt; + b->undo_list_ = (SREF (name, 0) != ' ') ? Qnil : Qt; reset_buffer (b); reset_buffer_local_variables (b, 1); - BUF_MARK (b) = Fmake_marker (); + b->mark_ = Fmake_marker (); BUF_MARKERS (b) = NULL; - BUF_NAME (b) = name; + b->name_ = name; b->owner = Qnil; b->prev_owner = Qnil; diff --git a/src/emacs.c b/src/emacs.c index f87c0a2f0ac..0ac070f8cd8 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1303,6 +1303,7 @@ main (int argc, char **argv) { init_alloc_once (); init_obarray (); + init_threads_once (); init_eval_once (); init_character_once (); init_charset_once (); diff --git a/src/marker.c b/src/marker.c index 99a8fc4d52a..8ffe17fcc4e 100644 --- a/src/marker.c +++ b/src/marker.c @@ -455,7 +455,7 @@ Returns nil if MARKER points into a dead buffer. */) does not preserve the buffer from being GC'd (it's weak), so markers have to be unlinked from their buffer as soon as the buffer is killed. */ - eassert (!NILP (XBUFFER (buf)->name)); + eassert (!NILP (BUF_NAME (XBUFFER (buf)))); return buf; } return Qnil; diff --git a/src/thread.c b/src/thread.c index 2a3199b70b9..9cfa19fbbaa 100644 --- a/src/thread.c +++ b/src/thread.c @@ -461,6 +461,16 @@ other_threads_p (void) } void +init_threads_once (void) +{ + primary_thread.size = PSEUDOVECSIZE (struct thread_state, m_gcprolist); + primary_thread.next = NULL; + primary_thread.func = Qnil; + primary_thread.initial_specpdl = Qnil; + XSETPVECTYPE (&primary_thread, PVEC_THREAD); +} + +void init_threads (void) { pthread_mutex_init (&global_lock, NULL); diff --git a/src/thread.h b/src/thread.h index 556fad2f200..423944fe653 100644 --- a/src/thread.h +++ b/src/thread.h @@ -126,6 +126,8 @@ extern __thread struct thread_state *current_thread; extern void init_threads P_ ((void)); +extern void init_threads_once P_ ((void)); + extern void thread_yield P_ ((void)); extern void syms_of_threads P_ ((void)); -- 2.11.4.GIT