* duration of a single Scheme session.
*/
-#include "scheme.h"
#include "prims.h"
#include "os.h"
#include "usrdef.h"
#include "cmpgc.h"
#include <ctype.h>
+#ifdef ENABLE_SMP
+static pthread_mutex_t mutex = MUTEX_INITIALIZER;
+# ifdef ENABLE_DEBUGGING_TOOLS
+static bool locked_p = false;
+# endif
+#endif
+
#ifndef UPDATE_PRIMITIVE_TABLE_HOOK
# define UPDATE_PRIMITIVE_TABLE_HOOK(low, high) do { } while (0)
#endif
grow_primitive_tables (void)
{
unsigned long new_size = (MAX_PRIMITIVE + (MAX_PRIMITIVE / 10));
+#if defined(ENABLE_SMP) && defined(ENABLE_DEBUGGING_TOOLS)
+ assert (locked_p == true);
+#endif
COPY_TABLE (Primitive_Arity_Table, Static_Primitive_Arity_Table, int, int);
COPY_TABLE (Primitive_Count_Table, Static_Primitive_Count_Table, int, int);
COPY_TABLE (Primitive_Name_Table,
/* MAX_STATIC_PRIMITIVE is the index of the last primitive */
MAX_PRIMITIVE = (MAX_STATIC_PRIMITIVE + 1);
+#if defined(ENABLE_SMP) && defined(ENABLE_DEBUGGING_TOOLS)
+ /* Avoid annoying the assert. */
+ locked_p = true;
grow_primitive_tables ();
+ locked_p = false;
+#else
+ grow_primitive_tables ();
+#endif
tree_error_message = ((char *) NULL);
prim_procedure_tree = (tree_build (MAX_PRIMITIVE, Primitive_Name_Table, 0));
unsigned long index;
SCHEME_OBJECT primitive;
const char * ndocstr = docstr;
- tree_node prim = (tree_lookup (prim_procedure_tree, name));
+ tree_node prim;
+
+ LOCK();
+ prim = (tree_lookup (prim_procedure_tree, name));
if (prim != ((tree_node) NULL))
{
if ((((PRIMITIVE_ARITY (primitive)) != nargs_hi)
&& ((PRIMITIVE_ARITY (primitive)) != UNKNOWN_PRIMITIVE_ARITY))
|| ((IMPLEMENTED_PRIMITIVE_P (primitive)) && (! override_p)))
- return (LONG_TO_UNSIGNED_FIXNUM (PRIMITIVE_NUMBER (primitive)));
+ {
+ UNLOCK();
+ return (LONG_TO_UNSIGNED_FIXNUM (PRIMITIVE_NUMBER (primitive)));
+ }
if (docstr == 0)
ndocstr = (Primitive_Documentation_Table[index]);
}
{
outf_error (tree_error_message, tree_error_noise);
tree_error_message = ((char *) NULL);
+ UNLOCK();
return (SHARP_F);
}
prim_procedure_tree = prim;
Primitive_Count_Table[index] = (nargs_hi * (sizeof (SCHEME_OBJECT)));
Primitive_Documentation_Table[index] = ndocstr;
UPDATE_PRIMITIVE_TABLE_HOOK (index, (index + 1));
+ UNLOCK();
return (primitive);
}
\f
|| (arity == (PRIMITIVE_ARITY (primitive))))
return (primitive);
- if ((PRIMITIVE_ARITY (primitive)) == UNKNOWN_PRIMITIVE_ARITY)
- {
- /* We've just learned the arity of the primitive. */
- (Primitive_Arity_Table[PRIMITIVE_NUMBER (primitive)]) = arity;
- return (primitive);
- }
-
/* Arity mismatch, notify the runtime system. */
return (LONG_TO_FIXNUM (PRIMITIVE_ARITY (primitive)));
}