case scm_tc7_vector:
case scm_tc7_wvect:
return scm_i_vector_equal_p (x, y);
-
- case scm_tc7_hashtable:
- return scm_i_hashtable_equal_p (x, y);
}
/* Check equality between structs of equal type (see cell-type test above). */
if (SCM_STRUCTP (x))
case scm_tc7_vector:
case scm_tc7_wvect:
case scm_tc7_hashtable:
+ case scm_tc7_fluid:
+ case scm_tc7_dynamic_state:
case scm_tc7_number:
case scm_tc7_string:
case scm_tc7_smob:
#include "libguile/_scm.h"
#include "libguile/print.h"
-#include "libguile/smob.h"
#include "libguile/dynwind.h"
#include "libguile/fluids.h"
#include "libguile/alist.h"
static size_t allocated_fluids_num = 0;
static char *allocated_fluids = NULL;
-static scm_t_bits tc16_fluid;
+#define IS_FLUID(x) (!SCM_IMP (x) && SCM_TYP7 (x) == scm_tc7_fluid)
+#define FLUID_NUM(x) ((size_t)SCM_CELL_WORD_1(x))
-#define IS_FLUID(x) SCM_SMOB_PREDICATE(tc16_fluid, (x))
-#define FLUID_NUM(x) ((size_t)SCM_SMOB_DATA(x))
-#define FLUID_NEXT(x) SCM_SMOB_OBJECT_2(x)
-#define FLUID_NEXT_LOC(x) SCM_SMOB_OBJECT_2_LOC(x)
-#define SET_FLUID_NEXT(x,y) SCM_SET_SMOB_OBJECT_2((x), (y))
-
-static scm_t_bits tc16_dynamic_state;
-
-#define IS_DYNAMIC_STATE(x) SCM_SMOB_PREDICATE(tc16_dynamic_state, (x))
-#define DYNAMIC_STATE_FLUIDS(x) SCM_SMOB_OBJECT(x)
-#define SET_DYNAMIC_STATE_FLUIDS(x, y) SCM_SET_SMOB_OBJECT((x), (y))
-#define DYNAMIC_STATE_NEXT(x) SCM_SMOB_OBJECT_2(x)
-#define DYNAMIC_STATE_NEXT_LOC(x) SCM_SMOB_OBJECT_2_LOC(x)
-#define SET_DYNAMIC_STATE_NEXT(x, y) SCM_SET_SMOB_OBJECT_2((x), (y))
+#define IS_DYNAMIC_STATE(x) (!SCM_IMP (x) && SCM_TYP7 (x) == scm_tc7_dynamic_state)
+#define DYNAMIC_STATE_FLUIDS(x) SCM_PACK (SCM_CELL_WORD_1 (x))
+#define SET_DYNAMIC_STATE_FLUIDS(x, y) SCM_SET_CELL_WORD_1 ((x), (SCM_UNPACK (y)))
\f
scm_i_pthread_mutex_unlock (&fluid_admin_mutex);
}
-static int
-fluid_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED)
+void
+scm_i_fluid_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED)
{
scm_puts ("#<fluid ", port);
scm_intprint ((int) FLUID_NUM (exp), 10, port);
scm_putc ('>', port);
- return 1;
}
static size_t
"with its own dynamic state, you can use fluids for thread local storage.")
#define FUNC_NAME s_scm_make_fluid
{
- SCM fluid;
-
- SCM_NEWSMOB2 (fluid, tc16_fluid,
- (scm_t_bits) next_fluid_num (), SCM_UNPACK (SCM_EOL));
-
- return fluid;
+ return scm_cell (scm_tc7_fluid, (scm_t_bits) next_fluid_num ());
}
#undef FUNC_NAME
scm_i_make_initial_dynamic_state ()
{
SCM fluids = scm_c_make_vector (allocated_fluids_len, SCM_BOOL_F);
- SCM state;
- SCM_NEWSMOB2 (state, tc16_dynamic_state,
- SCM_UNPACK (fluids), SCM_UNPACK (SCM_EOL));
- return state;
+ return scm_cell (scm_tc7_dynamic_state, SCM_UNPACK (fluids));
}
SCM_DEFINE (scm_make_dynamic_state, "make-dynamic-state", 0, 1, 0,
"or of the current dynamic state when @var{parent} is omitted.")
#define FUNC_NAME s_scm_make_dynamic_state
{
- SCM fluids, state;
+ SCM fluids;
if (SCM_UNBNDP (parent))
parent = scm_current_dynamic_state ();
- scm_assert_smob_type (tc16_dynamic_state, parent);
+ SCM_ASSERT (IS_DYNAMIC_STATE (parent), parent, SCM_ARG1, FUNC_NAME);
fluids = scm_vector_copy (DYNAMIC_STATE_FLUIDS (parent));
- SCM_NEWSMOB2 (state, tc16_dynamic_state,
- SCM_UNPACK (fluids), SCM_UNPACK (SCM_EOL));
-
- return state;
+ return scm_cell (scm_tc7_dynamic_state, SCM_UNPACK (fluids));
}
#undef FUNC_NAME
{
scm_i_thread *t = SCM_I_CURRENT_THREAD;
SCM old = t->dynamic_state;
- scm_assert_smob_type (tc16_dynamic_state, state);
+ SCM_ASSERT (IS_DYNAMIC_STATE (state), state, SCM_ARG1, FUNC_NAME);
t->dynamic_state = state;
return old;
}
scm_dynwind_current_dynamic_state (SCM state)
{
SCM loc = scm_cons (state, SCM_EOL);
- scm_assert_smob_type (tc16_dynamic_state, state);
+ SCM_ASSERT (IS_DYNAMIC_STATE (state), state, SCM_ARG1, NULL);
scm_dynwind_rewind_handler_with_scm (swap_dynamic_state, loc,
SCM_F_WIND_EXPLICITLY);
scm_dynwind_unwind_handler_with_scm (swap_dynamic_state, loc,
}
#undef FUNC_NAME
-void
-scm_fluids_prehistory ()
-{
- tc16_fluid = scm_make_smob_type ("fluid", 0);
- scm_set_smob_print (tc16_fluid, fluid_print);
-
- tc16_dynamic_state = scm_make_smob_type ("dynamic-state", 0);
-}
void
scm_init_fluids ()
#ifndef SCM_FLUIDS_H
#define SCM_FLUIDS_H
-/* Copyright (C) 1996,2000,2001, 2006, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1996,2000,2001, 2006, 2008, 2009 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
/* Fluids.
- Fluids are objects of a certain type (a smob) that can hold one SCM
- value per dynamic state. That is, modifications to this value are
- only visible to code that executes with the same dynamic state as
- the modifying code. When a new dynamic state is constructed, it
- inherits the values from its parent. Because each thread executes
- with its own dynamic state, you can use fluids for thread local
- storage.
-
- Each fluid is identified by a small integer. This integer is used
- to index a vector that holds the values of all fluids. A dynamic
- state consists of this vector, wrapped in a smob so that the vector
- can grow.
+ Fluids are objects of a certain type that can hold one SCM value per
+ dynamic state. That is, modifications to this value are only visible
+ to code that executes with the same dynamic state as the modifying
+ code. When a new dynamic state is constructed, it inherits the
+ values from its parent. Because each thread executes with its own
+ dynamic state, you can use fluids for thread local storage.
+
+ Each fluid is identified by a small integer. This integer is used to
+ index a vector that holds the values of all fluids. A dynamic state
+ consists of this vector, wrapped in an object so that the vector can
+ grow.
*/
/* The fastest way to acces/modify the value of a fluid. These macros
SCM_INTERNAL SCM scm_i_make_initial_dynamic_state (void);
-SCM_INTERNAL void scm_fluids_prehistory (void);
+SCM_INTERNAL void scm_i_fluid_print (SCM exp, SCM port, scm_print_state *pstate);
SCM_INTERNAL void scm_init_fluids (void);
#endif /* SCM_FLUIDS_H */
return "pws";
case scm_tc7_hashtable:
return "hashtable";
+ case scm_tc7_fluid:
+ return "fluid";
+ case scm_tc7_dynamic_state:
+ return "dynamic state";
case scm_tc7_wvect:
return "weak vector";
case scm_tc7_vector:
SCM scm_class_boolean, scm_class_char, scm_class_pair;
SCM scm_class_procedure, scm_class_string, scm_class_symbol;
SCM scm_class_procedure_with_setter, scm_class_primitive_generic;
-SCM scm_class_vector, scm_class_hashtable, scm_class_null;
+SCM scm_class_vector, scm_class_null;
SCM scm_class_integer, scm_class_real, scm_class_complex, scm_class_fraction;
SCM scm_class_unknown;
SCM scm_class_top, scm_class_object, scm_class_class;
SCM scm_class_scm;
SCM scm_class_int, scm_class_float, scm_class_double;
+static SCM class_hashtable;
+static SCM class_fluid;
+static SCM class_dynamic_state;
+
/* Port classes. Allocate 3 times the maximum number of port types so that
input ports, output ports, and in/out ports can be stored at different
offsets. See `SCM_IN_PCLASS_INDEX' et al. */
case scm_tc7_wvect:
return scm_class_vector;
case scm_tc7_hashtable:
- return scm_class_hashtable;
+ return class_hashtable;
+ case scm_tc7_fluid:
+ return class_fluid;
+ case scm_tc7_dynamic_state:
+ return class_dynamic_state;
case scm_tc7_string:
return scm_class_string;
case scm_tc7_number:
scm_class_class, scm_class_top, SCM_EOL);
make_stdcls (&scm_class_vector, "<vector>",
scm_class_class, scm_class_top, SCM_EOL);
- make_stdcls (&scm_class_hashtable, "<hashtable>",
+ make_stdcls (&class_hashtable, "<hashtable>",
+ scm_class_class, scm_class_top, SCM_EOL);
+ make_stdcls (&class_fluid, "<fluid>",
+ scm_class_class, scm_class_top, SCM_EOL);
+ make_stdcls (&class_dynamic_state, "<dynamic-state>",
scm_class_class, scm_class_top, SCM_EOL);
make_stdcls (&scm_class_number, "<number>",
scm_class_class, scm_class_top, SCM_EOL);
SCM_API SCM scm_class_procedure_with_setter;
SCM_API SCM scm_class_primitive_generic;
SCM_API SCM scm_class_vector;
-SCM_API SCM scm_class_hashtable;
SCM_API SCM scm_class_null;
SCM_API SCM scm_class_real;
SCM_API SCM scm_class_complex;
scm_puts (">", port);
}
-SCM
-scm_i_hashtable_equal_p (SCM x, SCM y)
-{
- return SCM_BOOL_F;
-}
-
SCM
scm_c_make_hash_table (unsigned long k)
SCM_API SCM scm_hash_for_each_handle (SCM proc, SCM hash);
SCM_API SCM scm_hash_map_to_list (SCM proc, SCM hash);
SCM_INTERNAL void scm_i_hashtable_print (SCM exp, SCM port, scm_print_state *pstate);
-SCM_INTERNAL SCM scm_i_hashtable_equal_p (SCM x, SCM y);
SCM_INTERNAL void scm_init_hashtab (void);
#endif /* SCM_HASHTAB_H */
scm_threads_prehistory (base);
scm_ports_prehistory ();
scm_smob_prehistory ();
- scm_fluids_prehistory ();
scm_weaks_prehistory ();
#ifdef GUILE_DEBUG_MALLOC
scm_debug_malloc_prehistory ();
case scm_tc7_hashtable:
scm_i_hashtable_print (exp, port, pstate);
break;
+ case scm_tc7_fluid:
+ scm_i_fluid_print (exp, port, pstate);
+ break;
case scm_tc7_wvect:
ENTER_NESTED_DATA (pstate, exp, circref);
if (SCM_IS_WHVEC (exp))
#define scm_tc7_stringbuf 39
#define scm_tc7_bytevector 77
-/* Many of the following should be turned
- * into structs or smobs. We need back some
- * of these 7 bit tags! */
-
#define scm_tc7_pws 31
-
#define scm_tc7_hashtable 29
-#define scm_tc7_unused_2 37
-#define scm_tc7_unused_3 45
+#define scm_tc7_fluid 37
+#define scm_tc7_dynamic_state 45
+
#define scm_tc7_unused_4 47
#define scm_tc7_unused_5 53
#define scm_tc7_unused_6 55