Skip to content

Commit 7c5a893

Browse files
author
jan.nijtmans
committed
Rebase to trunk
2 parents 98be046 + aa05291 commit 7c5a893

19 files changed

+2337
-29
lines changed

tests/memorymodule.test

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
if {"::tcltest" ni [namespace children]} {
2+
package require tcltest 2.5
3+
namespace import -force ::tcltest::*
4+
}
5+
6+
testConstraint memorymoduletest [expr {0 == [catch {zipfs mount dltest/memorymoduletest.zip [file join [zipfs root] memorymoduletest]}]}]
7+
8+
lappend auto_path [file join [zipfs root] memorymoduletest]
9+
10+
testConstraint thread [expr {[catch {package require thread 3.0}] == 0}]
11+
12+
test memorymodule-1.0 {info loaded} memorymoduletest {
13+
package require memorymoduletest
14+
info loaded {} Memorymoduletest
15+
} [file join [zipfs root] memorymoduletest/tcl9memorymoduletest.dll]
16+
17+
test memorymodule-1.1 {GetModuleFileNameA} memorymoduletest {
18+
package require memorymoduletest
19+
GetModuleFileNameA
20+
} //zipfs:/memorymoduletest/tcl9memorymoduletest.dll
21+
22+
test memorymodule-1.2 {GetModuleFileNameW} memorymoduletest {
23+
package require memorymoduletest
24+
GetModuleFileNameW
25+
} //zipfs:/memorymoduletest/tcl9memorymoduletest.dll
26+
27+
test memorymodule-2.0 {LTS, create thread before accessing var} -constraints {memorymoduletest thread} -body {
28+
package require Thread
29+
package require threadvartest
30+
set t1 [thread::create]
31+
ThreadVar 15; # Set ThreadVar to 15 in the main thread
32+
thread::preserve $t1
33+
thread::send $t1 {
34+
lappend auto_path [file join [zipfs root] memorymoduletest]
35+
package require threadvartest
36+
# set ThreadVar to 16 in the subthread
37+
ThreadVar 16
38+
return [ThreadVar]
39+
} result
40+
thread::release $t1
41+
# ThreadVar in main thread should be unchanged (15)
42+
list [ThreadVar] $result
43+
} -result {15 16}
44+
45+
test memorymodule-2.1 {LTS, create thread after accessing var} -constraints {memorymoduletest thread} -body {
46+
package require Thread
47+
package require threadvartest
48+
ThreadVar 15; # Set ThreadVar to 15 in the main thread
49+
set t1 [thread::create]; #create thread _before_ setting the variable
50+
thread::preserve $t1
51+
thread::send $t1 {
52+
lappend auto_path [file join [zipfs root] memorymoduletest]
53+
package require threadvartest
54+
# set ThreadVar to 16 in the subthread
55+
ThreadVar 16
56+
return [ThreadVar]
57+
} result
58+
thread::release $t1
59+
# ThreadVar in main thread should be unchanged (15)
60+
list [ThreadVar] $result
61+
} -result {15 16}
62+
63+
test memorymodule-2.2 {nexted exception} -constraints memorymoduletest -body {
64+
NestedException
65+
} -result 1
66+
67+
test memorymodule-3.0 {Multiple DLL's} -constraints memorymoduletest -body {
68+
package require threadvar2test
69+
package require threadvartest
70+
set result {}
71+
ThreadVar 15; # Modify first module
72+
lappend result [ThreadVar]; # Check first module
73+
ThreadVar2 16; # Modify second module
74+
lappend result [ThreadVar]; # Check first module
75+
ThreadVar 17; # Modify first module
76+
lappend result [ThreadVar2]; # Check second module
77+
} -result {15 15 16}
78+
79+
test memorymodule-3.1 {Multiple DLL's} -constraints memorymoduletest -body {
80+
package require threadvar2test
81+
package require threadvartest
82+
# The two _tls_index should NOT be the same
83+
expr {[ThreadVar -index] == [ThreadVar2 -index]}
84+
} -result 0
85+
86+
test memorymodule-3.2 {_tls_index} -constraints {memorymoduletest thread} -body {
87+
set t1 [thread::create];
88+
thread::preserve $t1
89+
thread::send $t1 {
90+
lappend auto_path [file join [zipfs root] memorymoduletest]
91+
package require threadvartest
92+
return [list [expr {[ThreadVar -index] > 0}] [ThreadVar -start] [ThreadVar -end]]
93+
} result
94+
thread::release $t1
95+
lappend result [expr {[ThreadVar -index] > 0}] [ThreadVar -start] [ThreadVar -end]
96+
} -result {1 0 0 1 0 0}
97+
98+
# cleanup
99+
::tcltest::cleanupTests
100+
return
101+

unix/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2410,7 +2410,7 @@ dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tclConfig.h.in $(UNIX_DIR)/tcl.pc.in gen
24102410
$(DIST_INSTALL_SCRIPT) $(TOP_DIR)/win/configure $(DISTDIR)/win
24112411
$(DIST_INSTALL_DATA) $(TOP_DIR)/win/*.c $(TOP_DIR)/win/*.ico $(TOP_DIR)/win/*.rc \
24122412
$(TOP_DIR)/win/tclWinInt.h $(TOP_DIR)/win/tclWinPort.h \
2413-
$(DISTDIR)/win
2413+
$(TOP_DIR)/win/MemoryModule.h $(DISTDIR)/win
24142414
$(DIST_INSTALL_DATA) $(TOP_DIR)/win/*.bat $(DISTDIR)/win
24152415
$(DIST_INSTALL_DATA) $(TOP_DIR)/win/*.vc $(DISTDIR)/win
24162416
$(DIST_INSTALL_DATA) $(TOP_DIR)/win/tcl.ds* $(DISTDIR)/win

win/Makefile.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ CFLAGS_OPTIMIZE = @CFLAGS_OPTIMIZE@
8585
#CFLAGS = $(CFLAGS_DEBUG)
8686
#CFLAGS = $(CFLAGS_OPTIMIZE)
8787
#CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE)
88-
CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -DMP_FIXED_CUTOFFS -DUTF8PROC_STATIC -D__USE_MINGW_ANSI_STDIO=0
88+
CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -DMP_FIXED_CUTOFFS -DUTF8PROC_STATIC -D__USE_MINGW_ANSI_STDIO=0 -DTCL_LOAD_FROM_MEMORY
8989

9090
# To compile without backward compatibility and deprecated code uncomment the
9191
# following
@@ -531,7 +531,10 @@ tcltest.cmd: Makefile
531531

532532
tcltest.sh: tcltest.cmd
533533

534-
tcltest: binaries $(TEST_EXE_FILE) $(TEST_DLL_FILE) $(CAT32) tcltest.cmd
534+
thrower.dll: dltest/thrower.dll
535+
cp dltest/thrower.dll .
536+
537+
tcltest: binaries $(TEST_EXE_FILE) $(TEST_DLL_FILE) $(CAT32) tcltest.cmd thrower.dll
535538

536539
binaries: $(TCL_STUB_LIB_FILE) @LIBRARIES@ winextensions ${TCL_ZIP_FILE} $(TCLSH)
537540

@@ -660,6 +663,9 @@ tclTestMain.${OBJEXT}: tclAppInit.c
660663
tclWinInit.${OBJEXT}: tclWinInit.c
661664
$(CC) -c $(CC_SWITCHES) -DBUILD_tcl $(EXTFLAGS) @DEPARG@ $(CC_OBJNAME)
662665

666+
tclWinLoad.${OBJEXT}: tclWinLoad.c
667+
$(CC) -c $(CC_SWITCHES) -DBUILD_tcl -DUNICODE -D_UNICODE $(EXTFLAGS) @DEPARG@ $(CC_OBJNAME)
668+
663669
tclWinPipe.${OBJEXT}: tclWinPipe.c
664670
$(CC) -c $(CC_SWITCHES) -DBUILD_tcl $(EXTFLAGS) @DEPARG@ $(CC_OBJNAME)
665671

0 commit comments

Comments
 (0)