summaryrefslogtreecommitdiff
path: root/libguile/fluids.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-12-05 10:52:18 +0100
committerAndy Wingo <wingo@pobox.com>2009-12-05 10:52:18 +0100
commit9ea31741dad29ae123e468a203b72df6d190f6e1 (patch)
treebc1424d37a358b5f4fcfa756492134517ad07b32 /libguile/fluids.c
parentc99de5aa275b15af207c0dba9717d6b865684fc4 (diff)
downloadguile-9ea31741dad29ae123e468a203b72df6d190f6e1.tar.gz
fluids are tc7 objects
If you're wondering what I'm doing, I'm trying to eventually reimplement smobs in terms of structs, so that applicable smobs can just follow the applicable struct dispatch path. But to do that I have to get structs initialized before things that use smobs, which means transforming a bunch of smobby things to tc7 things. But this transformation is good for performance anyway, and we currently have a glut of unused tc7s, so here we go... * libguile/tags.h (scm_tc7_fluid, scm_tc7_dynamic_state): Fluids (and dynamic states) now have tc7s. * libguile/fluids.h: Remove scm_fluids_prehistory, and add internal scm_i_fluid_print. Update a comment. * libguile/fluids.c: Update for tc7 representation. Also remove the next pointers while we're at it, as they aren't used in the new BDW GC. * libguile/eq.c (scm_equal_p): Remove the hashtable case. Hashtables could never be equal? before, I don't see why to add stubs doing the same thing now. * libguile/print.c (iprin1): * libguile/gc.c (scm_i_tag_name): * libguile/evalext.c (scm_self_evaluating_p): Add fluid and dynamic_state cases. * libguile/goops.h: Remove scm_class_hashtable; it will be static. * libguile/goops.c: Make <hashtable> static, and add <fluid> and <dynamic-state> classes. * libguile/hashtab.h: * libguile/hashtab.c: Remove scm_i_hashtable_equal_p. * libguile/init.c (scm_i_init_guile): Remove call to fluids_prehistory.
Diffstat (limited to 'libguile/fluids.c')
-rw-r--r--libguile/fluids.c59
1 files changed, 14 insertions, 45 deletions
diff --git a/libguile/fluids.c b/libguile/fluids.c
index 75dcccf75..bb9447fd5 100644
--- a/libguile/fluids.c
+++ b/libguile/fluids.c
@@ -26,7 +26,6 @@
#include "libguile/_scm.h"
#include "libguile/print.h"
-#include "libguile/smob.h"
#include "libguile/dynwind.h"
#include "libguile/fluids.h"
#include "libguile/alist.h"
@@ -66,22 +65,12 @@ static size_t allocated_fluids_len = 0;
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)))
@@ -115,13 +104,12 @@ grow_dynamic_state (SCM state)
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
@@ -190,12 +178,7 @@ SCM_DEFINE (scm_make_fluid, "make-fluid", 0, 0, 0,
"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
@@ -406,10 +389,7 @@ SCM
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,
@@ -418,17 +398,14 @@ 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
@@ -465,7 +442,7 @@ SCM_DEFINE (scm_set_current_dynamic_state, "set-current-dynamic-state", 1,0,0,
{
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;
}
@@ -481,7 +458,7 @@ void
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,
@@ -514,14 +491,6 @@ SCM_DEFINE (scm_with_dynamic_state, "with-dynamic-state", 2, 0, 0,
}
#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 ()