summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rw-r--r--unix/Makefile.in61
-rw-r--r--unix/tclUnixPipe.c8
-rw-r--r--unix/tclUnixThrd.c7
3 files changed, 58 insertions, 18 deletions
diff --git a/unix/Makefile.in b/unix/Makefile.in
index fe95797..d45b139 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -290,7 +290,42 @@ TCLTEST_OBJS = tclTestInit.o tclTest.o tclTestObj.o tclTestProcBodyObj.o \
XTTEST_OBJS = xtTestInit.o tclTest.o tclTestObj.o tclTestProcBodyObj.o \
tclThreadTest.o tclUnixTest.o tclXtNotify.o tclXtTest.o
-GENERIC_OBJS = regcomp.o regexec.o regfree.o regerror.o tclAlloc.o \
+#--------------------------------------------------------------------------
+# Choose the default allocator to link in. Override with the env-var
+# TCL_ALLOCATOR if present. Note that all allocators will be compiled,
+# changing them just requires relinking.
+#--------------------------------------------------------------------------
+
+PURIFY = tclAllocPurify.o
+PURIFY_FLAGS = -DPURIFY% -DTCL_ALLOCATOR=PURIFY
+
+NATIVE = tclAllocNative.o
+NATIVE_FLAGS = -DTCL_ALLOCATOR=NATIVE
+
+ZIPPY = tclAllocZippy.o
+ZIPPY_FLAGS = -DUSE_THREAD_ALLOC% -DTCL_ALLOCATOR=ZIPPY
+
+ALLOCATOR_DEFAULT = $(NATIVE)
+ALLOCATORS = $(PURIFY) $(NATIVE) $(ZIPPY)
+
+WHERE = $(CC_SWITCHES) $(CFLAGS)
+
+ifdef TCL_ALLOCATOR
+ ALLOCATOR = $($(TCL_ALLOCATOR))
+else ifneq (,$(filter $(PURIFY_FLAGS), $(WHERE)))
+ ALLOCATOR = $(PURIFY)
+else ifneq (,$(filter $(NATIVE_FLAGS), $(WHERE)))
+ ALLOCATOR = $(NATIVE)
+else ifneq (,$(filter $(ZIPPY_FLAGS), $(WHERE)))
+ ALLOCATOR = $(ZIPPY)
+endif
+
+ifeq (,$(filter $(ALLOCATORS), $(ALLOCATOR)))
+ ALLOCATOR = $(ALLOCATOR_DEFAULT)
+endif
+
+GENERIC_OBJS = $(ALLOCATOR) \
+ regcomp.o regexec.o regfree.o regerror.o \
tclAsync.o tclBasic.o tclBinary.o tclCkalloc.o tclClock.o \
tclCmdAH.o tclCmdIL.o tclCmdMZ.o tclCompCmds.o tclCompCmdsSZ.o \
tclCompExpr.o tclCompile.o tclConfig.o tclDate.o tclDictObj.o \
@@ -305,10 +340,10 @@ GENERIC_OBJS = regcomp.o regexec.o regfree.o regerror.o tclAlloc.o \
tclPreserve.o tclProc.o tclRegexp.o \
tclResolve.o tclResult.o tclScan.o tclStringObj.o \
tclStrToD.o tclThread.o \
- tclThreadAlloc.o tclThreadJoin.o tclThreadStorage.o tclStubInit.o \
+ tclThreadJoin.o tclThreadStorage.o tclStubInit.o \
tclTimer.o tclTrace.o tclUtf.o tclUtil.o tclVar.o tclZlib.o \
tclTomMathInterface.o \
- tclAssembly.o
+ tclAssembly.o
OO_OBJS = tclOO.o tclOOBasic.o tclOOCall.o tclOODefineCmds.o tclOOInfo.o \
tclOOMethod.o tclOOStubInit.o
@@ -384,7 +419,9 @@ GENERIC_SRCS = \
$(GENERIC_DIR)/regexec.c \
$(GENERIC_DIR)/regfree.c \
$(GENERIC_DIR)/regerror.c \
- $(GENERIC_DIR)/tclAlloc.c \
+ $(GENERIC_DIR)/tclAllocNative.c \
+ $(GENERIC_DIR)/tclAllocPurify.c \
+ $(GENERIC_DIR)/tclAllocZippy.c \
$(GENERIC_DIR)/tclAssembly.c \
$(GENERIC_DIR)/tclAsync.c \
$(GENERIC_DIR)/tclBasic.c \
@@ -447,7 +484,6 @@ GENERIC_SRCS = \
$(GENERIC_DIR)/tclTestObj.c \
$(GENERIC_DIR)/tclTestProcBodyObj.c \
$(GENERIC_DIR)/tclThread.c \
- $(GENERIC_DIR)/tclThreadAlloc.c \
$(GENERIC_DIR)/tclThreadJoin.c \
$(GENERIC_DIR)/tclThreadStorage.c \
$(GENERIC_DIR)/tclTimer.c \
@@ -611,7 +647,7 @@ doc:
# The following target is configured by autoconf to generate either a shared
# library or non-shared library for Tcl.
-${LIB_FILE}: ${OBJS} ${STUB_LIB_FILE}
+${LIB_FILE}: $(ALLOCATORS) ${OBJS} ${STUB_LIB_FILE}
rm -f $@
@MAKE_LIB@
@if test "x$(DLL_INSTALL_DIR)" = "x$(BIN_INSTALL_DIR)"; then\
@@ -1049,8 +1085,14 @@ regerror.o: $(REGHDRS) $(GENERIC_DIR)/regerrs.h $(GENERIC_DIR)/regerror.c
tclAppInit.o: $(UNIX_DIR)/tclAppInit.c
$(CC) -c $(APP_CC_SWITCHES) $(UNIX_DIR)/tclAppInit.c
-tclAlloc.o: $(GENERIC_DIR)/tclAlloc.c
- $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclAlloc.c
+tclAllocNative.o: $(GENERIC_DIR)/tclAllocNative.c $(GENERIC_DIR)/tclAllocZippy.c
+ $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclAllocNative.c
+
+tclAllocPurify.o: $(GENERIC_DIR)/tclAllocPurify.c
+ $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclAllocPurify.c
+
+tclAllocZippy.o: $(GENERIC_DIR)/tclAllocZippy.c
+ $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclAllocZippy.c
tclAssembly.o: $(GENERIC_DIR)/tclAssembly.c $(COMPILEHDR)
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclAssembly.c
@@ -1325,9 +1367,6 @@ tclTimer.o: $(GENERIC_DIR)/tclTimer.c
tclThread.o: $(GENERIC_DIR)/tclThread.c
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclThread.c
-tclThreadAlloc.o: $(GENERIC_DIR)/tclThreadAlloc.c
- $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclThreadAlloc.c
-
tclThreadJoin.o: $(GENERIC_DIR)/tclThreadJoin.c
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclThreadJoin.c
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c
index 9c21b28..249a703 100644
--- a/unix/tclUnixPipe.c
+++ b/unix/tclUnixPipe.c
@@ -430,8 +430,8 @@ TclpCreateProcess(
* deallocated later
*/
- dsArray = TclStackAlloc(interp, argc * sizeof(Tcl_DString));
- newArgv = TclStackAlloc(interp, (argc+1) * sizeof(char *));
+ dsArray = ckalloc(argc * sizeof(Tcl_DString));
+ newArgv = ckalloc((argc+1) * sizeof(char *));
newArgv[argc] = NULL;
for (i = 0; i < argc; i++) {
newArgv[i] = Tcl_UtfToExternalDString(NULL, argv[i], -1, &dsArray[i]);
@@ -503,8 +503,8 @@ TclpCreateProcess(
for (i = 0; i < argc; i++) {
Tcl_DStringFree(&dsArray[i]);
}
- TclStackFree(interp, newArgv);
- TclStackFree(interp, dsArray);
+ ckfree(newArgv);
+ ckfree(dsArray);
if (pid == -1) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index 789dbb6..e178041 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -674,12 +674,11 @@ TclpInetNtoa(
#endif
}
-#ifdef TCL_THREADS
+#if defined(TCL_THREADS)
/*
* Additions by AOL for specialized thread memory allocator.
*/
-#ifdef USE_THREAD_ALLOC
static volatile int initialized = 0;
static pthread_key_t key;
@@ -716,6 +715,7 @@ TclpFreeAllocMutex(
free(lockPtr);
}
+
void
TclpFreeAllocCache(
void *ptr)
@@ -758,8 +758,9 @@ TclpSetAllocCache(
{
pthread_setspecific(key, arg);
}
-#endif /* USE_THREAD_ALLOC */
+#endif
+#ifdef TCL_THREADS
void *
TclpThreadCreateKey(void)
{