2002-10-16 15:54:23 +00:00
|
|
|
|
/* classes: h_files */
|
|
|
|
|
|
|
2002-12-02 00:59:27 +00:00
|
|
|
|
#ifndef SCM_NULL_THREADS_H
|
|
|
|
|
|
#define SCM_NULL_THREADS_H
|
2002-10-16 15:54:23 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
/* Copyright (C) 2005 Free Software Foundation, Inc.
|
2002-10-16 15:54:23 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* 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 2.1 of the License, or (at your option) any later version.
|
2002-10-16 15:54:23 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
2002-10-16 15:54:23 +00:00
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
2002-10-16 15:54:23 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2005-05-23 19:57:22 +00:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-04-05 19:15:35 +00:00
|
|
|
|
*/
|
2002-10-16 15:54:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
/* The null-threads implementation. We provide the subset of the
|
|
|
|
|
|
standard pthread API that is used by Guile, but no new threads can
|
|
|
|
|
|
be created.
|
* __scm.h (SCM_ALLOW_INTS_ONLY): Removed.
(SCM_NONREC_CRITICAL_SECTION_START,
SCM_NONREC_CRITICAL_SECTION_END, SCM_REC_CRITICAL_SECTION_START,
SCM_REC_CRITICAL_SECTION_END): New macros.
(SCM_CRITICAL_SECTION_START/END): Defined here.
* eval.c: Insert SOURCE_SECTION_START / SOURCE_SECTION_END around
the three calls to scm_m_expand_body.
* gc.h: #include "libguile/pthread-threads.h";
(SCM_FREELIST_CREATE, SCM_FREELIST_LOC): New macros.
* gc.c (scm_i_freelist, scm_i_freelist2): Defined to be of type
scm_t_key;
* gc.c, gc-freelist.c, inline.h: Use SCM_FREELIST_LOC for freelist
access.
* gc-freelist.c (scm_gc_init_freelist): Create freelist keys.
* gc-freelist.c, threads.c (really_launch): Use
SCM_FREELIST_CREATE.
* gc-malloc.c (scm_realloc, scm_gc_register_collectable_memory):
* gc.c (scm_i_expensive_validation_check, scm_gc,
scm_gc_for_newcell): Put threads to sleep before doing GC-related
heap administration so that those pieces of code are executed
single-threaded. We might consider rewriting these code sections
in terms of a "call_gc_code_singly_threaded" construct instead of
calling the pair of scm_i_thread_put_to_sleep () and
scm_i_thread_wake_up (). Also, we would want to have as many of
these sections eleminated.
* init.c (scm_init_guile_1): Call scm_threads_prehistory.
* inline.h: #include "libguile/threads.h"
* pthread-threads.h: Macros now conform more closely to the
pthreads interface. Some of them now take a second argument.
* threads.c, threads.h: Many changes.
* configure.in: Temporarily replaced "copt" threads option with new
option "pthreads".
(USE_PTHREAD_THREADS): Define if pthreads configured.
2002-12-09 13:42:58 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
This file merely exits so that Guile can be compiled and run
|
|
|
|
|
|
without using pthreads. Improving performance via optimizations
|
|
|
|
|
|
that are possible in a single-threaded program is not a primary
|
|
|
|
|
|
goal.
|
2002-12-02 00:59:27 +00:00
|
|
|
|
*/
|
2002-10-16 15:54:23 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
#include <errno.h>
|
2002-12-02 00:59:27 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
/* Threads
|
2002-12-02 00:59:27 +00:00
|
|
|
|
*/
|
2005-03-02 20:42:01 +00:00
|
|
|
|
#define scm_i_pthread_t int
|
|
|
|
|
|
#define scm_i_pthread_self() 0
|
|
|
|
|
|
#define scm_i_pthread_create(t,a,f,d) (*(t)=0, (void)(f), ENOSYS)
|
|
|
|
|
|
#define scm_i_pthread_detach(t) do { } while (0)
|
|
|
|
|
|
#define scm_i_pthread_exit(v) exit(0)
|
|
|
|
|
|
#define scm_i_sched_yield() 0
|
|
|
|
|
|
|
|
|
|
|
|
/* Signals
|
|
|
|
|
|
*/
|
|
|
|
|
|
#define scm_i_pthread_sigmask sigprocmask
|
2002-12-02 00:59:27 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
/* Mutexes
|
|
|
|
|
|
*/
|
|
|
|
|
|
#define SCM_I_PTHREAD_MUTEX_INITIALIZER 0
|
|
|
|
|
|
#define scm_i_pthread_mutex_t int
|
|
|
|
|
|
#define scm_i_pthread_mutex_init(m,a) (*(m) = 0)
|
|
|
|
|
|
#define scm_i_pthread_mutex_destroy(m) do { (void)(m); } while(0)
|
|
|
|
|
|
#define scm_i_pthread_mutex_trylock(m) ((*(m))++)
|
|
|
|
|
|
#define scm_i_pthread_mutex_lock(m) ((*(m))++)
|
|
|
|
|
|
#define scm_i_pthread_mutex_unlock(m) ((*(m))--)
|
2005-10-23 20:47:49 +00:00
|
|
|
|
#define scm_i_pthread_mutexattr_recursive 0
|
2005-03-02 20:42:01 +00:00
|
|
|
|
|
|
|
|
|
|
/* Condition variables
|
|
|
|
|
|
*/
|
|
|
|
|
|
#define SCM_I_PTHREAD_COND_INITIALIZER 0
|
|
|
|
|
|
#define scm_i_pthread_cond_t int
|
|
|
|
|
|
#define scm_i_pthread_cond_init(c,a) (*(c) = 0)
|
|
|
|
|
|
#define scm_i_pthread_cond_destroy(c) do { (void)(c); } while(0)
|
|
|
|
|
|
#define scm_i_pthread_cond_signal(c) (*(c) = 1)
|
|
|
|
|
|
#define scm_i_pthread_cond_broadcast(c) (*(c) = 1)
|
|
|
|
|
|
#define scm_i_pthread_cond_wait(c,m) (abort(), 0)
|
|
|
|
|
|
#define scm_i_pthread_cond_timedwait(c,m,t) (abort(), 0)
|
|
|
|
|
|
|
|
|
|
|
|
/* Onces
|
|
|
|
|
|
*/
|
|
|
|
|
|
#define scm_i_pthread_once_t int
|
|
|
|
|
|
#define SCM_I_PTHREAD_ONCE_INIT 0
|
|
|
|
|
|
#define scm_i_pthread_once(o,f) do { \
|
|
|
|
|
|
if(!*(o)) { *(o)=1; f (); } \
|
|
|
|
|
|
} while(0)
|
2002-12-02 00:59:27 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
/* Thread specific storage
|
|
|
|
|
|
*/
|
|
|
|
|
|
typedef struct scm_i_pthread_key_t {
|
|
|
|
|
|
struct scm_i_pthread_key_t *next;
|
|
|
|
|
|
void *value;
|
|
|
|
|
|
void (*destr_func) (void *);
|
|
|
|
|
|
} scm_i_pthread_key_t;
|
|
|
|
|
|
|
|
|
|
|
|
SCM_API int scm_i_pthread_key_create (scm_i_pthread_key_t *key,
|
|
|
|
|
|
void (*destr_func) (void *));
|
|
|
|
|
|
#define scm_i_pthread_setspecific(k,p) ((k).value = (p))
|
|
|
|
|
|
#define scm_i_pthread_getspecific(k) ((k).value)
|
|
|
|
|
|
|
|
|
|
|
|
/* Convenience functions
|
|
|
|
|
|
*/
|
|
|
|
|
|
#define scm_i_scm_pthread_mutex_lock scm_i_pthread_mutex_lock
|
|
|
|
|
|
#define scm_i_frame_pthread_mutex_lock scm_i_pthread_mutex_lock
|
|
|
|
|
|
#define scm_i_scm_pthread_cond_wait scm_i_pthread_cond_wait
|
|
|
|
|
|
#define scm_i_scm_pthread_cond_timedwait scm_i_pthread_cond_timedwait
|
2002-10-16 15:54:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
2002-12-02 00:59:27 +00:00
|
|
|
|
#endif /* SCM_NULL_THREADS_H */
|
2002-10-16 15:54:23 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|