void Ns_ThreadCreate(Ns_ThreadProc *proc, void *arg, long stacksize, Ns_Thread *resultPtr) { ThreadArg *argPtr; /* * Determine the stack size and add the guard. */ if (stacksize <= 0) { stacksize = Ns_ThreadStackSize(0); } if (stacksize < stackmin) { stacksize = stackmin; } /* * Create the thread. */ argPtr = ns_malloc(sizeof(ThreadArg)); argPtr->proc = proc; argPtr->arg = arg; argPtr->flags = resultPtr ? 0 : FLAG_DETACHED; strcpy(argPtr->parent, Ns_ThreadGetName()); NsCreateThread(argPtr, stacksize, resultPtr); }
void Msg(char *fmt,...) { va_list ap; char *s, *r; time_t now; time(&now); s = ns_ctime(&now); r = strchr(s, '\n'); if (r) { *r = '\0'; } va_start(ap, fmt); Ns_MutexLock(&mlock); printf("[%s][%s]: ", Ns_ThreadGetName(), s); vfprintf(stdout, fmt, ap); printf("\n"); Ns_MutexUnlock(&mlock); va_end(ap); }