summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixThrd.c
diff options
context:
space:
mode:
authorwelch <welch>1999-08-10 02:42:36 (GMT)
committerwelch <welch>1999-08-10 02:42:36 (GMT)
commit24e9f11aa2c7e32ed6e8a0e6a2c7ae4f0ff12bac (patch)
tree3dda6d8125f2a42360c01e1206096b0d0bd753f3 /unix/tclUnixThrd.c
parent3a26c6d4498ad6fad866d54c7b23cb221fe21898 (diff)
downloadtcl-24e9f11aa2c7e32ed6e8a0e6a2c7ae4f0ff12bac.zip
tcl-24e9f11aa2c7e32ed6e8a0e6a2c7ae4f0ff12bac.tar.gz
tcl-24e9f11aa2c7e32ed6e8a0e6a2c7ae4f0ff12bac.tar.bz2
Added Tcl_GetAllocMutex for use by tclAlloc.c and tclCkalloc.c
Diffstat (limited to 'unix/tclUnixThrd.c')
-rw-r--r--unix/tclUnixThrd.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index ac0804e..a9127a7 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -36,6 +36,13 @@ static pthread_mutex_t masterLock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t initLock = PTHREAD_MUTEX_INITIALIZER;
/*
+ * allocLock is used by Tcl's version of malloc for synchronization.
+ * For obvious reasons, cannot use any dyamically allocated storage.
+ */
+
+static pthread_mutex_t allocLock = PTHREAD_MUTEX_INITIALIZER;
+
+/*
* These are for the critical sections inside this file.
*/
@@ -248,45 +255,37 @@ TclpMasterUnlock()
#endif
}
-#ifdef TCL_THREADS
/*
*----------------------------------------------------------------------
*
- * TclpMutexInit --
- * TclpMutexLock --
- * TclpMutexUnlock --
+ * Tcl_GetAllocMutex
+ *
+ * This procedure returns a pointer to a statically initialized
+ * mutex for use by the memory allocator. The alloctor must
+ * use this lock, because all other locks are allocated...
*
- * These procedures use an explicitly initialized mutex.
- * These are used by memory allocators for their own mutex.
- *
* Results:
- * None.
+ * A pointer to a mutex that is suitable for passing to
+ * Tcl_MutexLock and Tcl_MutexUnlock.
*
* Side effects:
- * Initialize, Lock, and Unlock the mutex.
+ * None.
*
*----------------------------------------------------------------------
*/
-void
-TclpMutexInit(mPtr)
- TclpMutex *mPtr;
+Tcl_Mutex *
+Tcl_GetAllocMutex()
{
- pthread_mutex_init((pthread_mutex_t *)mPtr, NULL);
-}
-void
-TclpMutexLock(mPtr)
- TclpMutex *mPtr;
-{
- pthread_mutex_lock((pthread_mutex_t *)mPtr);
-}
-void
-TclpMutexUnlock(mPtr)
- TclpMutex *mPtr;
-{
- pthread_mutex_unlock((pthread_mutex_t *)mPtr);
+#ifdef TCL_THREADS
+ return (Tcl_Mutex *)&allocLock;
+#else
+ return NULL;
+#endif
}
+
+#ifdef TCL_THREADS
/*
*----------------------------------------------------------------------