THREAD_LOCAL gmp state

svn: r16168
This commit is contained in:
Kevin Tew 2009-09-29 16:01:36 +00:00
parent 28e84131a6
commit 95524d71a1
3 changed files with 23 additions and 5 deletions

View File

@ -438,6 +438,7 @@ static Scheme_Env *place_instance_init_post_kernel() {
scheme_init_regexp_places();
scheme_init_stx_places();
scheme_init_sema_places();
scheme_init_gmp_places();
env = scheme_make_empty_env();
scheme_set_param(scheme_current_config(), MZCONFIG_ENV, (Scheme_Object *)env);

View File

@ -17,13 +17,22 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#ifdef MZ_USE_PLACES
# if _MSC_VER
# define THREAD_LOCAL __declspec(thread)
# else
# define THREAD_LOCAL __thread
# endif
#else
# define THREAD_LOCAL /* empty */
#endif
#define _FORCE_INLINES
#define _EXTERN_INLINE /* empty */
extern void *scheme_malloc_gmp(unsigned long, void **mem_pool);
extern void scheme_free_gmp(void *, void **mem_pool);
static void *mem_pool = 0;
static THREAD_LOCAL void *mem_pool = 0;
#define MALLOC(amt) scheme_malloc_gmp(amt, &mem_pool)
#define FREE(p, s) scheme_free_gmp(p, &mem_pool)
@ -5688,11 +5697,11 @@ unsigned char __clz_tab[] =
typedef struct tmp_stack tmp_stack;
static unsigned long max_total_allocation = 0;
static unsigned long current_total_allocation = 0;
static THREAD_LOCAL unsigned long max_total_allocation = 0;
static THREAD_LOCAL unsigned long current_total_allocation = 0;
static tmp_stack xxx = {&xxx, &xxx, 0};
static tmp_stack *current = &xxx;
static THREAD_LOCAL tmp_stack xxx = {0, 0, 0};
static THREAD_LOCAL tmp_stack *current = 0;
/* The rounded size of the header of each allocation block. */
#define HSIZ ((sizeof (tmp_stack) + __TMP_ALIGN - 1) & -__TMP_ALIGN)
@ -5785,6 +5794,13 @@ __gmp_tmp_free (mark)
current->alloc_point = mark->alloc_point;
}
void scheme_init_gmp_places() {
xxx.end = &xxx;
xxx.alloc_point = &xxx;
xxx.prev = 0;
current = &xxx;
}
void scheme_gmp_tls_init(long *s)
{
s[0] = 0;

View File

@ -232,6 +232,7 @@ void scheme_init_regexp_places(void);
void scheme_init_stx_places(void);
void scheme_init_fun_places(void);
void scheme_init_sema_places(void);
void scheme_init_gmp_places(void);
void scheme_init_print_global_constants(void);
void register_network_evts();