[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
symbol interning and lookup not threadsafe
From: |
Andy Wingo |
Subject: |
symbol interning and lookup not threadsafe |
Date: |
Wed, 05 Jan 2011 16:24:57 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
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/
- symbol interning and lookup not threadsafe,
Andy Wingo <=