add: static Ns_TlsCleanup FreeTls;
context: static Ns_ThreadProc TclNsThread;/* * These macros are for critical sections within this file. */#define MASTER_LOCK	Ns_MasterLock()#define MASTER_UNLOCK	Ns_MasterUnlock()/* *---------------------------------------------------------------------- * * Tcl_CreateThread -- * *	This procedure creates a new thread. * * Results: *	TCL_OK if the thread could be created.  The thread ID is *	returned in a parameter. * * Side effects: *	A new thread is created. * *---------------------------------------------------------------------- */NS_EXPORT intTcl_CreateThread(idPtr, proc, clientData, stackSize, flags)    Tcl_ThreadId *idPtr;		/* Return, the ID of the thread */    Tcl_ThreadCreateProc proc;		/* Main() function of the thread */    ClientData clientData;		/* The one argument to Main() */    int stackSize;			/* New thread stack size. */    int flags;				/* Flags for new thread (ignored). */{    Ns_Thread tid;    ThreadArg *argPtr;    if (stackSize == TCL_THREAD_STACK_DEFAULT) {	stackSize = 0;    }    if (flags & TCL_THREAD_JOINABLE) {	flags = 0;    } else {	flags = NS_THREAD_DETACHED;    }    argPtr = NsAlloc(sizeof(ThreadArg));    argPtr->proc = proc;    argPtr->clientData = clientData;    Ns_ThreadCreate2(TclNsThread, argPtr, (long) stackSize, flags, &tid);    *idPtr = (Tcl_ThreadId) tid;    return TCL_OK;}/* *---------------------------------------------------------------------- * * TclNsThread -- * *	Tcl specific thread startup routine.  This is only required *	to handle the different proc types between Tcl and Ns threads. * * Results: *	None. * * Side effects: *	Depends on given thread start proc. * *---------------------------------------------------------------------- */static voidTclNsThread(void *arg){    ThreadArg *argPtr = arg;    Tcl_ThreadCreateProc *proc;    ClientData clientData;    proc = argPtr->proc;    clientData = argPtr->clientData;    NsFree(argPtr);    (*proc)(clientData);}