summaryrefslogtreecommitdiff
path: root/doc/ref
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2013-02-28 17:56:58 -0500
committerMark H Weaver <mhw@netris.org>2013-03-05 16:04:55 -0500
commitf57ea23ac8e1436f37ceeda3ea8625243c20e645 (patch)
tree9770b54992f625abae89964d8b6efea62d09dea6 /doc/ref
parent29ace173b170a5d77e6becb30fb1d9f253a373d5 (diff)
downloadguile-f57ea23ac8e1436f37ceeda3ea8625243c20e645.tar.gz
Fix thread-unsafe lazy initializations.
* libguile/debug.c (scm_local_eval): libguile/ports.c (scm_current_warning_port): libguile/strports.c (scm_eval_string_in_module): Perform lazy-initialization while holding a mutex. Use SCM_UNDEFINED as the uninitialized value. Use 'scm_c_*_variable'. * doc/ref/api-modules.texi (Accessing Modules from C): Fix 'my_eval_string' example to be thread-safe.
Diffstat (limited to 'doc/ref')
-rw-r--r--doc/ref/api-modules.texi16
1 files changed, 10 insertions, 6 deletions
diff --git a/doc/ref/api-modules.texi b/doc/ref/api-modules.texi
index b9befc00c..47b81601b 100644
--- a/doc/ref/api-modules.texi
+++ b/doc/ref/api-modules.texi
@@ -945,14 +945,18 @@ the @var{name} is not bound in the module, signals an error. Returns a
variable, always.
@example
-SCM my_eval_string (SCM str)
-@{
- static SCM eval_string_var = SCM_BOOL_F;
+static SCM eval_string_var;
- if (scm_is_false (eval_string_var))
- eval_string_var =
- scm_c_public_lookup ("ice-9 eval-string", "eval-string");
+/* NOTE: It is important that the call to 'my_init'
+ happens-before all calls to 'my_eval_string'. */
+void my_init (void)
+@{
+ eval_string_var = scm_c_public_lookup ("ice-9 eval-string",
+ "eval-string");
+@}
+SCM my_eval_string (SCM str)
+@{
return scm_call_1 (scm_variable_ref (eval_string_var), str);
@}
@end example