mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 17:20:29 +02:00
Arrange so that `SCM_I_CURRENT_THREAD' is not accessed outside of libguile.
* libguile/__scm.h (scm_async_tick): New declaration. (SCM_ASYNC_TICK)[!BUILDING_LIBGUILE]: Use `scm_async_tick ()'. * libguile/async.c (scm_critical_section_start, scm_critical_section_end, scm_async_tick): New functions. * libguile/async.h (scm_i_critical_section_mutex): Made internal. (scm_critical_section_start, scm_critical_section_end): New declarations. (SCM_CRITICAL_SECTION_START, SCM_CRITICAL_SECTION_END)[!BUILDING_LIBGUILE]: Use the same-named function (lower-case). * libguile/stackchk.h (SCM_STACK_OVERFLOW_P): Conditionalize on `BUILDING_LIBGUILE'. * libguile/threads.h (SCM_I_CURRENT_THREAD, scm_i_dynwinds, scm_i_set_dynwinds, scm_i_last_debug_frame, scm_i_set_last_debug_frame): Conditionalize on `BUILDING_LIBGUILE'.
This commit is contained in:
parent
b8ec9daba6
commit
46935a1fac
5 changed files with 79 additions and 26 deletions
|
@ -492,11 +492,24 @@ typedef long SCM_STACKITEM;
|
||||||
#define SCM_STACK_PTR(ptr) ((SCM_STACKITEM *) (void *) (ptr))
|
#define SCM_STACK_PTR(ptr) ((SCM_STACKITEM *) (void *) (ptr))
|
||||||
|
|
||||||
|
|
||||||
#define SCM_ASYNC_TICK /*fixme* should change names */ \
|
SCM_API void scm_async_tick (void);
|
||||||
do { \
|
|
||||||
if (SCM_I_CURRENT_THREAD->pending_asyncs) \
|
#ifdef BUILDING_LIBGUILE
|
||||||
scm_async_click (); \
|
|
||||||
} while (0)
|
/* FIXME: should change names */
|
||||||
|
# define SCM_ASYNC_TICK \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (SCM_I_CURRENT_THREAD->pending_asyncs) \
|
||||||
|
scm_async_click (); \
|
||||||
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
|
#else /* !BUILDING_LIBGUILE */
|
||||||
|
|
||||||
|
# define SCM_ASYNC_TICK (scm_async_tick ())
|
||||||
|
|
||||||
|
#endif /* !BUILDING_LIBGUILE */
|
||||||
|
|
||||||
|
|
||||||
/* Anthony Green writes:
|
/* Anthony Green writes:
|
||||||
|
|
|
@ -472,6 +472,29 @@ scm_dynwind_unblock_asyncs ()
|
||||||
scm_dynwind_unwind_handler (increase_block, t, SCM_F_WIND_EXPLICITLY);
|
scm_dynwind_unwind_handler (increase_block, t, SCM_F_WIND_EXPLICITLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* These are function variants of the same-named macros (uppercase) for use
|
||||||
|
outside of libguile. This is so that `SCM_I_CURRENT_THREAD', which may
|
||||||
|
reside in TLS, is not accessed from outside of libguile. It thus allows
|
||||||
|
libguile to be built with the "local-dynamic" TLS model. */
|
||||||
|
|
||||||
|
void
|
||||||
|
scm_critical_section_start (void)
|
||||||
|
{
|
||||||
|
SCM_CRITICAL_SECTION_START;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
scm_critical_section_end (void)
|
||||||
|
{
|
||||||
|
SCM_CRITICAL_SECTION_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
scm_async_tick (void)
|
||||||
|
{
|
||||||
|
SCM_ASYNC_TICK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,22 +57,34 @@ void scm_dynwind_unblock_asyncs (void);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Defined in threads.c. */
|
/* Defined in threads.c. */
|
||||||
extern scm_i_pthread_mutex_t scm_i_critical_section_mutex;
|
SCM_INTERNAL scm_i_pthread_mutex_t scm_i_critical_section_mutex;
|
||||||
|
|
||||||
#define SCM_CRITICAL_SECTION_START \
|
SCM_API void scm_critical_section_start (void);
|
||||||
do { \
|
SCM_API void scm_critical_section_end (void);
|
||||||
scm_i_pthread_mutex_lock (&scm_i_critical_section_mutex);\
|
|
||||||
SCM_I_CURRENT_THREAD->block_asyncs++; \
|
#ifdef BUILDING_LIBGUILE
|
||||||
SCM_I_CURRENT_THREAD->critical_section_level++; \
|
|
||||||
|
# define SCM_CRITICAL_SECTION_START \
|
||||||
|
do { \
|
||||||
|
scm_i_pthread_mutex_lock (&scm_i_critical_section_mutex); \
|
||||||
|
SCM_I_CURRENT_THREAD->block_asyncs++; \
|
||||||
|
SCM_I_CURRENT_THREAD->critical_section_level++; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define SCM_CRITICAL_SECTION_END \
|
# define SCM_CRITICAL_SECTION_END \
|
||||||
do { \
|
do { \
|
||||||
SCM_I_CURRENT_THREAD->critical_section_level--; \
|
SCM_I_CURRENT_THREAD->critical_section_level--; \
|
||||||
SCM_I_CURRENT_THREAD->block_asyncs--; \
|
SCM_I_CURRENT_THREAD->block_asyncs--; \
|
||||||
scm_i_pthread_mutex_unlock (&scm_i_critical_section_mutex); \
|
scm_i_pthread_mutex_unlock (&scm_i_critical_section_mutex); \
|
||||||
scm_async_click (); \
|
scm_async_click (); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#else /* !BUILDING_LIBGUILE */
|
||||||
|
|
||||||
|
# define SCM_CRITICAL_SECTION_START scm_critical_section_start ()
|
||||||
|
# define SCM_CRITICAL_SECTION_END scm_critical_section_end ()
|
||||||
|
|
||||||
|
#endif /* !BUILDING_LIBGUILE */
|
||||||
|
|
||||||
SCM_INTERNAL void scm_init_async (void);
|
SCM_INTERNAL void scm_init_async (void);
|
||||||
|
|
||||||
#if (SCM_ENABLE_DEPRECATED == 1)
|
#if (SCM_ENABLE_DEPRECATED == 1)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#ifndef SCM_STACKCHK_H
|
#ifndef SCM_STACKCHK_H
|
||||||
#define SCM_STACKCHK_H
|
#define SCM_STACKCHK_H
|
||||||
|
|
||||||
/* Copyright (C) 1995,1996,1998,2000, 2003, 2006, 2008 Free Software Foundation, Inc.
|
/* Copyright (C) 1995,1996,1998,2000, 2003, 2006, 2008, 2009 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
*/
|
*/
|
||||||
#define SCM_STACK_CHECKING_P SCM_STACK_LIMIT
|
#define SCM_STACK_CHECKING_P SCM_STACK_LIMIT
|
||||||
|
|
||||||
#ifdef STACK_CHECKING
|
#if defined BUILDING_LIBGUILE && defined STACK_CHECKING
|
||||||
# if SCM_STACK_GROWS_UP
|
# if SCM_STACK_GROWS_UP
|
||||||
# define SCM_STACK_OVERFLOW_P(s)\
|
# define SCM_STACK_OVERFLOW_P(s)\
|
||||||
(SCM_STACK_PTR (s) \
|
(SCM_STACK_PTR (s) \
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define SCM_CHECK_STACK /**/
|
# define SCM_CHECK_STACK /**/
|
||||||
#endif /* STACK_CHECKING */
|
#endif
|
||||||
|
|
||||||
SCM_API int scm_stack_checking_enabled_p;
|
SCM_API int scm_stack_checking_enabled_p;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#ifndef SCM_THREADS_H
|
#ifndef SCM_THREADS_H
|
||||||
#define SCM_THREADS_H
|
#define SCM_THREADS_H
|
||||||
|
|
||||||
/* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
|
/* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -192,15 +192,20 @@ SCM_API SCM scm_thread_exited_p (SCM thread);
|
||||||
|
|
||||||
SCM_API void scm_dynwind_critical_section (SCM mutex);
|
SCM_API void scm_dynwind_critical_section (SCM mutex);
|
||||||
|
|
||||||
#define SCM_I_CURRENT_THREAD \
|
#ifdef BUILDING_LIBGUILE
|
||||||
|
|
||||||
|
# define SCM_I_CURRENT_THREAD \
|
||||||
((scm_i_thread *) scm_i_pthread_getspecific (scm_i_thread_key))
|
((scm_i_thread *) scm_i_pthread_getspecific (scm_i_thread_key))
|
||||||
SCM_API scm_i_pthread_key_t scm_i_thread_key;
|
SCM_API scm_i_pthread_key_t scm_i_thread_key;
|
||||||
|
|
||||||
#define scm_i_dynwinds() (SCM_I_CURRENT_THREAD->dynwinds)
|
# define scm_i_dynwinds() (SCM_I_CURRENT_THREAD->dynwinds)
|
||||||
#define scm_i_set_dynwinds(w) (SCM_I_CURRENT_THREAD->dynwinds = (w))
|
# define scm_i_set_dynwinds(w) (SCM_I_CURRENT_THREAD->dynwinds = (w))
|
||||||
#define scm_i_last_debug_frame() (SCM_I_CURRENT_THREAD->last_debug_frame)
|
# define scm_i_last_debug_frame() (SCM_I_CURRENT_THREAD->last_debug_frame)
|
||||||
#define scm_i_set_last_debug_frame(f) \
|
# define scm_i_set_last_debug_frame(f) \
|
||||||
(SCM_I_CURRENT_THREAD->last_debug_frame = (f))
|
(SCM_I_CURRENT_THREAD->last_debug_frame = (f))
|
||||||
|
|
||||||
|
#endif /* BUILDING_LIBGUILE */
|
||||||
|
|
||||||
|
|
||||||
SCM_INTERNAL scm_i_pthread_mutex_t scm_i_misc_mutex;
|
SCM_INTERNAL scm_i_pthread_mutex_t scm_i_misc_mutex;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue