* symbol interning and lookup not threadsafe
@ 2011-01-05 21:24 Andy Wingo
2011-01-23 21:23 ` Andy Wingo
0 siblings, 1 reply; 2+ messages in thread
From: Andy Wingo @ 2011-01-05 21:24 UTC (permalink / raw)
To: bug-guile
Symbols get interned through scm_i_str2symbol, which looks like this:
/* Intern SYMBOL, an uninterned symbol. */
static void
intern_symbol (SCM symbol)
{
SCM slot, cell;
unsigned long hash;
hash = scm_i_symbol_hash (symbol) % SCM_HASHTABLE_N_BUCKETS (symbols);
slot = SCM_HASHTABLE_BUCKET (symbols, hash);
cell = scm_cons (symbol, SCM_UNDEFINED);
SCM_SET_HASHTABLE_BUCKET (symbols, hash, scm_cons (cell, slot));
SCM_HASHTABLE_INCREMENT (symbols);
if (SCM_HASHTABLE_N_ITEMS (symbols) > SCM_HASHTABLE_UPPER (symbols))
scm_i_rehash (symbols, scm_i_hash_symbol, 0, "intern_symbol");
}
static SCM
scm_i_str2symbol (SCM str)
{
SCM symbol;
size_t raw_hash = scm_i_string_hash (str);
symbol = lookup_interned_symbol (str, raw_hash);
if (scm_is_false (symbol))
{
/* The symbol was not found, create it. */
symbol = scm_i_make_symbol (str, 0, raw_hash,
scm_cons (SCM_BOOL_F, SCM_EOL));
intern_symbol (symbol);
}
return symbol;
}
This is not threadsafe.
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-23 21:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-05 21:24 symbol interning and lookup not threadsafe Andy Wingo
2011-01-23 21:23 ` Andy Wingo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).