diff options
author | Andy Wingo <wingo@pobox.com> | 2014-02-07 15:01:33 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2014-02-07 15:03:17 +0100 |
commit | dc7a33fa871c42d0474602f3560d3ce350e1f1c3 (patch) | |
tree | 37495605b40c19ca83decd2b191fdb31510531b9 /libguile/eval.c | |
parent | a1aae2c3a03afc542ab6a7c6672c5a645ac77b09 (diff) | |
parent | 60617d819d77a1b92ed6c557a0b49b8e9a8e97b9 (diff) | |
download | guile-dc7a33fa871c42d0474602f3560d3ce350e1f1c3.tar.gz |
Merge commit '60617d819d77a1b92ed6c557a0b49b8e9a8e97b9'
Conflicts:
libguile/continuations.c
libguile/eval.c
libguile/goops.c
libguile/instructions.c
Diffstat (limited to 'libguile/eval.c')
-rw-r--r-- | libguile/eval.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/libguile/eval.c b/libguile/eval.c index 3e828a178..39e66c5d7 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -1,5 +1,5 @@ /* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004, - * 2005,2006,2007,2008,2009,2010,2011,2012,2013 + * 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014 * Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or @@ -620,30 +620,37 @@ scm_apply_3 (SCM proc, SCM arg1, SCM arg2, SCM arg3, SCM args) return scm_apply_0 (proc, scm_cons (arg1, scm_cons2 (arg2, arg3, args))); } +static SCM map_var, for_each_var; + +static void init_map_var (void) +{ + map_var = scm_private_variable (scm_the_root_module (), + scm_from_latin1_symbol ("map")); +} + +static void init_for_each_var (void) +{ + for_each_var = scm_private_variable (scm_the_root_module (), + scm_from_latin1_symbol ("for-each")); +} SCM scm_map (SCM proc, SCM arg1, SCM args) { - static SCM var = SCM_BOOL_F; + static scm_i_pthread_once_t once = SCM_I_PTHREAD_ONCE_INIT; + scm_i_pthread_once (&once, init_map_var); - if (scm_is_false (var)) - var = scm_private_variable (scm_the_root_module (), - scm_from_latin1_symbol ("map")); - - return scm_apply_0 (scm_variable_ref (var), + return scm_apply_0 (scm_variable_ref (map_var), scm_cons (proc, scm_cons (arg1, args))); } SCM scm_for_each (SCM proc, SCM arg1, SCM args) { - static SCM var = SCM_BOOL_F; - - if (scm_is_false (var)) - var = scm_private_variable (scm_the_root_module (), - scm_from_latin1_symbol ("for-each")); + static scm_i_pthread_once_t once = SCM_I_PTHREAD_ONCE_INIT; + scm_i_pthread_once (&once, init_for_each_var); - return scm_apply_0 (scm_variable_ref (var), + return scm_apply_0 (scm_variable_ref (for_each_var), scm_cons (proc, scm_cons (arg1, args))); } |