Skip to content

Commit

Permalink
Use pre-compiled zip-file (with MSVC) for memorymodule testing. GCC-c…
Browse files Browse the repository at this point in the history
…ompiled dll's still have some problems, so disable memorymodule for them too.
  • Loading branch information
jan.nijtmans committed Jan 23, 2025
1 parent 3c2f1d2 commit 76109ad
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
4 changes: 1 addition & 3 deletions tests/memorymodule.test
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,15 @@ test memorymodule-2.2 {nexted exception} -constraints {memorymoduletest msvc} -b

test memorymodule-3.0 {_tls_index} -constraints {memorymoduletest thread msvc} -body {
set t1 [thread::create];
ThreadVar 18; # Set ThreadVar to 18 in the main thread
thread::preserve $t1
thread::send $t1 {
lappend auto_path [file join [zipfs root] memorymoduletest]
package require threadvartest
ThreadVar 19; # Set ThreadVar to 18 in the main thread
return [list [ThreadVar -index] [ThreadVar -start] [ThreadVar -end]]
} result
thread::release $t1
lappend result [ThreadVar -index] [ThreadVar -start] [ThreadVar -end]
} -result {6 0 0 6 0 0}
} -result {4 0 0 4 0 0}

# cleanup
::tcltest::cleanupTests
Expand Down
5 changes: 1 addition & 4 deletions win/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -1018,14 +1018,11 @@ install-private-headers: libraries

test: test-tcl test-packages

test-tcl: tcltest dltest/memorymoduletest.zip
test-tcl: tcltest
TCL_LIBRARY="$(LIBRARY_DIR)"; export TCL_LIBRARY; \
$(WINE) ./$(TCLSH) "$(ROOT_DIR_NATIVE)/tests/all.tcl" $(TESTFLAGS) \
-load "$(TEST_LOAD_FACILITIES)"

dltest/memorymoduletest.zip:
( cd dltest; make; )

# Useful target to launch a built tclsh with the proper path,...
runtest: tcltest
@TCL_LIBRARY="$(LIBRARY_DIR)"; export TCL_LIBRARY; \
Expand Down
11 changes: 6 additions & 5 deletions win/MemoryModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,29 +360,30 @@ FinalizeSections(PMEMORYMODULE module)
static BOOL
ExecuteTLS(PMEMORYMODULE module)
{
#ifndef TCL_LOAD_FROM_MEMORY
unsigned char *codeBase = module->codeBase;
PIMAGE_TLS_DIRECTORY tls;
PIMAGE_TLS_CALLBACK* callback;
#endif /* !TCL_LOAD_FROM_MEMORY */

PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_TLS);
if (directory->VirtualAddress == 0) {
return TRUE;
}

#ifdef TCL_LOAD_FROM_MEMORY
return FALSE;
#else
tls = (PIMAGE_TLS_DIRECTORY) (codeBase + directory->VirtualAddress);
callback = (PIMAGE_TLS_CALLBACK *) tls->AddressOfCallBacks;
if (callback) {
while (*callback) {
(*callback)((LPVOID) codeBase, DLL_PROCESS_ATTACH, NULL);
callback++;
}
#ifdef TCL_LOAD_FROM_MEMORY
} else {
/* When used inside Tcl, we don't support dll's using TLS */
return FALSE;
#endif /* TCL_LOAD_FROM_MEMORY */
}
return TRUE;
#endif /* TCL_LOAD_FROM_MEMORY */
}

static BOOL
Expand Down
5 changes: 4 additions & 1 deletion win/dltest/makefile.vc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ LDFLAGS = -nologo -debug -incremental:no -opt:ref
OBJS = memorymoduletest.obj

# targets
all: $(SHAREDLIB) $(IMPLIB) $(SHAREDLIB2) $(IMPLIB2)
all: memorymoduletest.zip

memorymoduletest.zip: $(SHAREDLIB) $(IMPLIB) $(SHAREDLIB2) $(IMPLIB2)
zip $@ *.dll pkgIndex.tcl

$(IMPLIB): $(SHAREDLIB)

Expand Down
Binary file added win/dltest/memorymoduletest.zip
Binary file not shown.
Binary file removed win/dltest/tcl9thread300.dll
Binary file not shown.

0 comments on commit 76109ad

Please sign in to comment.