summaryrefslogtreecommitdiff
path: root/libguile/threads.h
diff options
context:
space:
mode:
Diffstat (limited to 'libguile/threads.h')
-rw-r--r--libguile/threads.h109
1 files changed, 57 insertions, 52 deletions
diff --git a/libguile/threads.h b/libguile/threads.h
index 55c566d23..337dc83a9 100644
--- a/libguile/threads.h
+++ b/libguile/threads.h
@@ -1,35 +1,33 @@
-/* classes: h_files */
-
#ifndef SCM_THREADS_H
#define SCM_THREADS_H
-/* Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2006,
- * 2007, 2008, 2009, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
+/* Copyright 1996-1998,2000-2004,2006-2009,2011-2014,2018-2019
+ Free Software Foundation, Inc.
+
+ This file is part of Guile.
+
+ Guile is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Guile is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Guile. If not, see
+ <https://www.gnu.org/licenses/>. */
-#include "libguile/__scm.h"
#include "libguile/procs.h"
#include "libguile/throw.h"
#include "libguile/dynstack.h"
#include "libguile/iselect.h"
-#include "libguile/continuations.h"
+#include "libguile/smob.h"
+#include "libguile/vm.h"
#if SCM_USE_PTHREAD_THREADS
#include "libguile/pthread-threads.h"
@@ -41,6 +39,19 @@
+#define SCM_INLINE_GC_GRANULE_WORDS 2
+#define SCM_INLINE_GC_GRANULE_BYTES \
+ (sizeof(void *) * SCM_INLINE_GC_GRANULE_WORDS)
+
+/* A freelist set contains SCM_INLINE_GC_FREELIST_COUNT pointers to
+ singly linked lists of objects of different sizes, the ith one
+ containing objects i + 1 granules in size. This setting of
+ SCM_INLINE_GC_FREELIST_COUNT will hold freelists for allocations of
+ up to 256 bytes. */
+#define SCM_INLINE_GC_FREELIST_COUNT (256U / SCM_INLINE_GC_GRANULE_BYTES)
+
+
+
/* smob tags for the thread datatypes */
SCM_API scm_t_bits scm_tc16_thread;
SCM_API scm_t_bits scm_tc16_mutex;
@@ -48,8 +59,22 @@ SCM_API scm_t_bits scm_tc16_condvar;
struct scm_thread_wake_data;
-typedef struct scm_i_thread {
- struct scm_i_thread *next_thread;
+struct scm_thread {
+ struct scm_thread *next_thread;
+
+ /* VM state for this thread. */
+ struct scm_vm vm;
+
+ /* For system asyncs.
+ */
+ SCM pending_asyncs; /* The thunks to be run at the next
+ safe point. Accessed atomically. */
+ unsigned int block_asyncs; /* Non-zero means that asyncs should
+ not be run. */
+
+ /* Thread-local freelists; see gc-inline.h. */
+ void *freelists[SCM_INLINE_GC_FREELIST_COUNT];
+ void *pointerless_freelists[SCM_INLINE_GC_FREELIST_COUNT];
SCM handle;
scm_i_pthread_t pthread;
@@ -67,10 +92,6 @@ typedef struct scm_i_thread {
scm_i_pthread_cond_t sleep_cond;
int sleep_pipe[2];
- /* Thread-local freelists; see gc-inline.h. */
- void **freelists;
- void **pointerless_freelists;
-
/* Other thread local things.
*/
scm_t_dynamic_state *dynamic_state;
@@ -78,13 +99,6 @@ typedef struct scm_i_thread {
/* The dynamic stack. */
scm_t_dynstack dynstack;
- /* For system asyncs.
- */
- SCM pending_asyncs; /* The thunks to be run at the next
- safe point. Accessed atomically. */
- unsigned int block_asyncs; /* Non-zero means that asyncs should
- not be run. */
-
/* The current continuation root and the stack base for it.
The continuation root is an arbitrary but unique object that
@@ -101,18 +115,15 @@ typedef struct scm_i_thread {
SCM continuation_root;
SCM_STACKITEM *continuation_base;
- /* For keeping track of the stack and registers. */
- struct scm_vm *vp;
+ /* Stack base. Used when checking for C stack overflow. */
SCM_STACKITEM *base;
- scm_i_jmp_buf regs;
-#ifdef __ia64__
- void *register_backing_store_base;
- scm_t_contregs *pending_rbs_continuation;
-#endif
-} scm_i_thread;
+
+ /* JIT state; NULL until this thread needs to JIT-compile something. */
+ struct scm_jit_state *jit_state;
+};
#define SCM_I_IS_THREAD(x) SCM_SMOB_PREDICATE (scm_tc16_thread, x)
-#define SCM_I_THREAD_DATA(x) ((scm_i_thread *) SCM_SMOB_DATA (x))
+#define SCM_I_THREAD_DATA(x) ((scm_thread *) SCM_SMOB_DATA (x))
#define SCM_VALIDATE_THREAD(pos, a) \
scm_assert_smob_type (scm_tc16_thread, (a))
@@ -175,13 +186,13 @@ SCM_INTERNAL scm_i_pthread_key_t scm_i_thread_key;
# ifdef SCM_HAVE_THREAD_STORAGE_CLASS
-SCM_INTERNAL SCM_THREAD_LOCAL scm_i_thread *scm_i_current_thread;
+SCM_INTERNAL SCM_THREAD_LOCAL scm_thread *scm_i_current_thread;
# define SCM_I_CURRENT_THREAD (scm_i_current_thread)
# else /* !SCM_HAVE_THREAD_STORAGE_CLASS */
# define SCM_I_CURRENT_THREAD \
- ((scm_i_thread *) scm_i_pthread_getspecific (scm_i_thread_key))
+ ((scm_thread *) scm_i_pthread_getspecific (scm_i_thread_key))
# endif /* !SCM_HAVE_THREAD_STORAGE_CLASS */
@@ -213,9 +224,3 @@ SCM_API SCM scm_total_processor_count (void);
SCM_API SCM scm_current_processor_count (void);
#endif /* SCM_THREADS_H */
-
-/*
- Local Variables:
- c-file-style: "gnu"
- End:
-*/