w_rc_t sthread_t::cold_startup() { _class_list = new sthread_list_t(W_LIST_ARG(sthread_t, _class_link), &_class_list_lock); if (_class_list == 0) W_FATAL(fcOUTOFMEMORY); // initialize the global RNG struct timeval now; gettimeofday(&now, NULL); // Set the seed for the clib random-number generator, which // we use to seed the per-thread RNG ::srand(now.tv_usec); /* * Boot the main thread onto the current (system) stack. */ sthread_main_t *main = new sthread_main_t; if (!main) W_FATAL(fcOUTOFMEMORY); me_lval() = _main_thread = main; W_COERCE( main->fork() ); if (me() != main) W_FATAL(stINTERNAL); #if defined(PURIFY) /* The main thread is different from all other threads. */ purify_name_thread(me()->name()); #endif return RCOK; }
static PyObject* pure_purify_name_thread(PyObject *self, PyObject *args) { /* can't strictly use call_stringarg_function since * purify_name_thread takes a const char*, not a char* */ int status; char* stringarg; if (!PyArg_ParseTuple(args, "s:purify_name_thread", &stringarg)) return NULL; status = purify_name_thread(stringarg); return Py_BuildValue("i", status); }