Skip to content

Commit 6ae631d

Browse files
committed
add windows 32 bit to test matrix
See #302
1 parent 5e6fc94 commit 6ae631d

File tree

5 files changed

+100
-4
lines changed

5 files changed

+100
-4
lines changed

ci/travis_linux_install

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -x
44

55
sudo apt-get remove -y llvm-*
66
sudo rm -rf /usr/local/*
7-
sudo apt-get install -y clang-5.0 libclang-5.0 libclang-5.0-dev llvm-5.0 llvm-5.0-dev liblld-5.0 liblld-5.0-dev cmake
7+
sudo apt-get install -y clang-5.0 libclang-5.0 libclang-5.0-dev llvm-5.0 llvm-5.0-dev liblld-5.0 liblld-5.0-dev cmake wine1.6-amd64

ci/travis_linux_script

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,22 @@ cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd) -DZIG_LIBC_LIB_DIR=$(dirname $($CC -print
1313
make VERBOSE=1
1414
make install
1515
./zig build --build-file ../build.zig test
16+
17+
./zig test ../std/behavior.zig --target-os windows --target-arch x86_64 --target-environ msvc
18+
wine64 test.exe
19+
20+
./zig test ../std/behavior.zig --target-os windows --target-arch i386 --target-environ msvc
21+
wine test.exe
22+
23+
./zig test ../std/behavior.zig --target-os windows --target-arch x86_64 --target-environ msvc --release-fast
24+
wine64 test.exe
25+
26+
./zig test ../std/behavior.zig --target-os windows --target-arch i386 --target-environ msvc --release-fast
27+
wine test.exe
28+
29+
# TODO fix bug
30+
# ./zig test ../std/behavior.zig --target-os windows --target-arch x86_64 --target-environ msvc --release-safe
31+
# wine64 test.exe
32+
33+
./zig test ../std/behavior.zig --target-os windows --target-arch i386 --target-environ msvc --release-safe
34+
wine test.exe

std/rand.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,16 @@ fn MersenneTwister(
164164

165165
while (i < n - m) : (i += 1) {
166166
const x = (mt.array[i] & UM) | (mt.array[i + 1] & LM);
167-
mt.array[i] = mt.array[i + m] ^ (x >> 1) ^ mag01[x & 0x1];
167+
mt.array[i] = mt.array[i + m] ^ (x >> 1) ^ mag01[usize(x & 0x1)];
168168
}
169169

170170
while (i < n - 1) : (i += 1) {
171171
const x = (mt.array[i] & UM) | (mt.array[i + 1] & LM);
172-
mt.array[i] = mt.array[i + m - n] ^ (x >> 1) ^ mag01[x & 0x1];
172+
mt.array[i] = mt.array[i + m - n] ^ (x >> 1) ^ mag01[usize(x & 0x1)];
173173

174174
}
175175
const x = (mt.array[i] & UM) | (mt.array[0] & LM);
176-
mt.array[i] = mt.array[m - 1] ^ (x >> 1) ^ mag01[x & 0x1];
176+
mt.array[i] = mt.array[m - 1] ^ (x >> 1) ^ mag01[usize(x & 0x1)];
177177

178178
mt.index = 0;
179179
}

std/special/compiler_rt/index.zig

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,44 @@ export nakedcc fn __aeabi_uidivmod() {
110110
@setGlobalLinkage(__aeabi_uidivmod, builtin.GlobalLinkage.Internal);
111111
}
112112

113+
// _chkstk (_alloca) routine - probe stack between %esp and (%esp-%eax) in 4k increments,
114+
// then decrement %esp by %eax. Preserves all registers except %esp and flags.
115+
// This routine is windows specific
116+
// http://msdn.microsoft.com/en-us/library/ms648426.aspx
117+
export nakedcc fn _chkstk() align(4) {
118+
@setDebugSafety(this, false);
119+
120+
if (comptime builtin.os == builtin.Os.windows) {
121+
if (comptime builtin.arch == builtin.Arch.i386) {
122+
asm volatile (
123+
\\ push %%ecx
124+
\\ cmp $0x1000,%%eax
125+
\\ lea 8(%%esp),%%ecx // esp before calling this routine -> ecx
126+
\\ jb 1f
127+
\\ 2:
128+
\\ sub $0x1000,%%ecx
129+
\\ test %%ecx,(%%ecx)
130+
\\ sub $0x1000,%%eax
131+
\\ cmp $0x1000,%%eax
132+
\\ ja 2b
133+
\\ 1:
134+
\\ sub %%eax,%%ecx
135+
\\ test %%ecx,(%%ecx)
136+
\\
137+
\\ lea 4(%%esp),%%eax // load pointer to the return address into eax
138+
\\ mov %%ecx,%%esp // install the new top of stack pointer into esp
139+
\\ mov -4(%%eax),%%ecx // restore ecx
140+
\\ push (%%eax) // push return address onto the stack
141+
\\ sub %%esp,%%eax // restore the original value in eax
142+
\\ ret
143+
);
144+
unreachable;
145+
}
146+
}
147+
148+
@setGlobalLinkage(_chkstk, builtin.GlobalLinkage.Internal);
149+
}
150+
113151
export nakedcc fn __chkstk() align(4) {
114152
@setDebugSafety(this, false);
115153

@@ -144,6 +182,40 @@ export nakedcc fn __chkstk() align(4) {
144182
@setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal);
145183
}
146184

185+
// _chkstk routine
186+
// This routine is windows specific
187+
// http://msdn.microsoft.com/en-us/library/ms648426.aspx
188+
export nakedcc fn __chkstk_ms() align(4) {
189+
@setDebugSafety(this, false);
190+
191+
if (comptime builtin.os == builtin.Os.windows) {
192+
if (comptime builtin.arch == builtin.Arch.i386) {
193+
asm volatile (
194+
\\ push %%ecx
195+
\\ push %%eax
196+
\\ cmp $0x1000,%%eax
197+
\\ lea 12(%%esp),%%ecx
198+
\\ jb 1f
199+
\\ 2:
200+
\\ sub $0x1000,%%ecx
201+
\\ test %%ecx,(%%ecx)
202+
\\ sub $0x1000,%%eax
203+
\\ cmp $0x1000,%%eax
204+
\\ ja 2b
205+
\\ 1:
206+
\\ sub %%eax,%%ecx
207+
\\ test %%ecx,(%%ecx)
208+
\\ pop %%eax
209+
\\ pop %%ecx
210+
\\ ret
211+
);
212+
unreachable;
213+
}
214+
}
215+
216+
@setGlobalLinkage(__chkstk_ms, builtin.GlobalLinkage.Internal);
217+
}
218+
147219
export nakedcc fn ___chkstk_ms() align(4) {
148220
@setDebugSafety(this, false);
149221

test/tests.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ const test_targets = []TestTarget {
4141
.arch = builtin.Arch.x86_64,
4242
.environ = builtin.Environ.msvc,
4343
},
44+
TestTarget {
45+
.os = builtin.Os.windows,
46+
.arch = builtin.Arch.i386,
47+
.environ = builtin.Environ.msvc,
48+
},
4449
};
4550

4651
error TestFailed;

0 commit comments

Comments
 (0)