summaryrefslogtreecommitdiff
path: root/libguile/fluids.c
diff options
context:
space:
mode:
Diffstat (limited to 'libguile/fluids.c')
-rw-r--r--libguile/fluids.c98
1 files changed, 53 insertions, 45 deletions
diff --git a/libguile/fluids.c b/libguile/fluids.c
index c3dd1c9ea..f62693338 100644
--- a/libguile/fluids.c
+++ b/libguile/fluids.c
@@ -1,21 +1,21 @@
-/* Copyright (C) 1996,1997,2000,2001, 2004, 2006, 2007, 2008, 2009, 2010,
- * 2011, 2012, 2013, 2017 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
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
+/* Copyright 1996-1997,2000-2001,2004,2006-2013,2017-2018
+ Free Software Foundation, Inc.
+
+ This file is part of Guile.
+
+ Guile 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 3 of the License, or
+ (at your option) any later version.
+
+ Guile is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Guile. If not, see
+ <https://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -24,18 +24,25 @@
#include <stdio.h>
#include <string.h>
-#include "libguile/_scm.h"
-#include "libguile/atomics-internal.h"
-#include "libguile/cache-internal.h"
-#include "libguile/print.h"
-#include "libguile/dynwind.h"
-#include "libguile/fluids.h"
-#include "libguile/alist.h"
-#include "libguile/eval.h"
-#include "libguile/ports.h"
-#include "libguile/deprecation.h"
-#include "libguile/validate.h"
-#include "libguile/bdw-gc.h"
+#include "alist.h"
+#include "atomics-internal.h"
+#include "bdw-gc.h"
+#include "cache-internal.h"
+#include "deprecation.h"
+#include "dynwind.h"
+#include "eval.h"
+#include "gsubr.h"
+#include "hashtab.h"
+#include "list.h"
+#include "pairs.h"
+#include "ports.h"
+#include "print.h"
+#include "threads.h"
+#include "variable.h"
+#include "weak-table.h"
+
+#include "fluids.h"
+
/* A dynamic state associates fluids with values. There are two
representations of a dynamic state in Guile: the active
@@ -363,6 +370,17 @@ fluid_ref (scm_t_dynamic_state *dynamic_state, SCM fluid)
return val;
}
+SCM
+scm_i_fluid_ref (scm_thread *thread, SCM fluid)
+{
+ SCM ret = fluid_ref (thread->dynamic_state, fluid);
+
+ if (SCM_UNBNDP (ret))
+ scm_misc_error ("fluid-ref", "unbound fluid: ~S", scm_list_1 (fluid));
+
+ return ret;
+}
+
SCM_DEFINE (scm_fluid_ref, "fluid-ref", 1, 0, 0,
(SCM fluid),
"Return the value associated with @var{fluid} in the current\n"
@@ -370,12 +388,8 @@ SCM_DEFINE (scm_fluid_ref, "fluid-ref", 1, 0, 0,
"its default value.")
#define FUNC_NAME s_scm_fluid_ref
{
- SCM ret;
SCM_VALIDATE_FLUID (1, fluid);
- ret = fluid_ref (SCM_I_CURRENT_THREAD->dynamic_state, fluid);
- if (SCM_UNBNDP (ret))
- scm_misc_error ("fluid-ref", "unbound fluid: ~S", scm_list_1 (fluid));
- return ret;
+ return scm_i_fluid_ref (SCM_I_CURRENT_THREAD, fluid);
}
#undef FUNC_NAME
@@ -502,7 +516,7 @@ scm_c_with_fluids (SCM fluids, SCM values, SCM (*cproc) (), void *cdata)
{
SCM ans;
long flen, vlen, i;
- scm_i_thread *thread = SCM_I_CURRENT_THREAD;
+ scm_thread *thread = SCM_I_CURRENT_THREAD;
SCM_VALIDATE_LIST_COPYLEN (1, fluids, flen);
SCM_VALIDATE_LIST_COPYLEN (2, values, vlen);
@@ -539,7 +553,7 @@ scm_c_with_fluid (SCM fluid, SCM value, SCM (*cproc) (), void *cdata)
#define FUNC_NAME "scm_c_with_fluid"
{
SCM ans;
- scm_i_thread *thread = SCM_I_CURRENT_THREAD;
+ scm_thread *thread = SCM_I_CURRENT_THREAD;
scm_dynstack_push_fluid (&thread->dynstack, fluid, value,
thread->dynamic_state);
@@ -610,7 +624,7 @@ SCM_DEFINE (scm_set_current_dynamic_state, "set-current-dynamic-state", 1,0,0,
"and return the previous current dynamic state object.")
#define FUNC_NAME s_scm_set_current_dynamic_state
{
- scm_i_thread *t = SCM_I_CURRENT_THREAD;
+ scm_thread *t = SCM_I_CURRENT_THREAD;
SCM old = scm_current_dynamic_state ();
SCM_ASSERT (is_dynamic_state (state), state, SCM_ARG1, FUNC_NAME);
restore_dynamic_state (get_dynamic_state (state), t->dynamic_state);
@@ -673,11 +687,5 @@ SCM_DEFINE (scm_with_dynamic_state, "with-dynamic-state", 2, 0, 0,
void
scm_init_fluids ()
{
-#include "libguile/fluids.x"
+#include "fluids.x"
}
-
-/*
- Local Variables:
- c-file-style: "gnu"
- End:
-*/