aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-10-01 11:11:38 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-10-01 11:11:38 -0400
commit6ae631d1a74e6918a67f55217a2581c65672b4dc (patch)
tree1359a3d8bb59e5b2258d00eb71f8907d271edfb4 /std
parent5e6fc94b7f43dda028de779a874f12591fa0a50d (diff)
downloadzig-6ae631d1a74e6918a67f55217a2581c65672b4dc.tar.gz
zig-6ae631d1a74e6918a67f55217a2581c65672b4dc.zip
add windows 32 bit to test matrix
See #302
Diffstat (limited to 'std')
-rw-r--r--std/rand.zig6
-rw-r--r--std/special/compiler_rt/index.zig72
2 files changed, 75 insertions, 3 deletions
diff --git a/std/rand.zig b/std/rand.zig
index f61c100e53..4e8bcde4ef 100644
--- a/std/rand.zig
+++ b/std/rand.zig
@@ -164,16 +164,16 @@ fn MersenneTwister(
while (i < n - m) : (i += 1) {
const x = (mt.array[i] & UM) | (mt.array[i + 1] & LM);
- mt.array[i] = mt.array[i + m] ^ (x >> 1) ^ mag01[x & 0x1];
+ mt.array[i] = mt.array[i + m] ^ (x >> 1) ^ mag01[usize(x & 0x1)];
}
while (i < n - 1) : (i += 1) {
const x = (mt.array[i] & UM) | (mt.array[i + 1] & LM);
- mt.array[i] = mt.array[i + m - n] ^ (x >> 1) ^ mag01[x & 0x1];
+ mt.array[i] = mt.array[i + m - n] ^ (x >> 1) ^ mag01[usize(x & 0x1)];
}
const x = (mt.array[i] & UM) | (mt.array[0] & LM);
- mt.array[i] = mt.array[m - 1] ^ (x >> 1) ^ mag01[x & 0x1];
+ mt.array[i] = mt.array[m - 1] ^ (x >> 1) ^ mag01[usize(x & 0x1)];
mt.index = 0;
}
diff --git a/std/special/compiler_rt/index.zig b/std/special/compiler_rt/index.zig
index d005c92ba1..39b2b5b8ab 100644
--- a/std/special/compiler_rt/index.zig
+++ b/std/special/compiler_rt/index.zig
@@ -110,6 +110,44 @@ export nakedcc fn __aeabi_uidivmod() {
@setGlobalLinkage(__aeabi_uidivmod, builtin.GlobalLinkage.Internal);
}
+// _chkstk (_alloca) routine - probe stack between %esp and (%esp-%eax) in 4k increments,
+// then decrement %esp by %eax. Preserves all registers except %esp and flags.
+// This routine is windows specific
+// http://msdn.microsoft.com/en-us/library/ms648426.aspx
+export nakedcc fn _chkstk() align(4) {
+ @setDebugSafety(this, false);
+
+ if (comptime builtin.os == builtin.Os.windows) {
+ if (comptime builtin.arch == builtin.Arch.i386) {
+ asm volatile (
+ \\ push %%ecx
+ \\ cmp $0x1000,%%eax
+ \\ lea 8(%%esp),%%ecx // esp before calling this routine -> ecx
+ \\ jb 1f
+ \\ 2:
+ \\ sub $0x1000,%%ecx
+ \\ test %%ecx,(%%ecx)
+ \\ sub $0x1000,%%eax
+ \\ cmp $0x1000,%%eax
+ \\ ja 2b
+ \\ 1:
+ \\ sub %%eax,%%ecx
+ \\ test %%ecx,(%%ecx)
+ \\
+ \\ lea 4(%%esp),%%eax // load pointer to the return address into eax
+ \\ mov %%ecx,%%esp // install the new top of stack pointer into esp
+ \\ mov -4(%%eax),%%ecx // restore ecx
+ \\ push (%%eax) // push return address onto the stack
+ \\ sub %%esp,%%eax // restore the original value in eax
+ \\ ret
+ );
+ unreachable;
+ }
+ }
+
+ @setGlobalLinkage(_chkstk, builtin.GlobalLinkage.Internal);
+}
+
export nakedcc fn __chkstk() align(4) {
@setDebugSafety(this, false);
@@ -144,6 +182,40 @@ export nakedcc fn __chkstk() align(4) {
@setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal);
}
+// _chkstk routine
+// This routine is windows specific
+// http://msdn.microsoft.com/en-us/library/ms648426.aspx
+export nakedcc fn __chkstk_ms() align(4) {
+ @setDebugSafety(this, false);
+
+ if (comptime builtin.os == builtin.Os.windows) {
+ if (comptime builtin.arch == builtin.Arch.i386) {
+ asm volatile (
+ \\ push %%ecx
+ \\ push %%eax
+ \\ cmp $0x1000,%%eax
+ \\ lea 12(%%esp),%%ecx
+ \\ jb 1f
+ \\ 2:
+ \\ sub $0x1000,%%ecx
+ \\ test %%ecx,(%%ecx)
+ \\ sub $0x1000,%%eax
+ \\ cmp $0x1000,%%eax
+ \\ ja 2b
+ \\ 1:
+ \\ sub %%eax,%%ecx
+ \\ test %%ecx,(%%ecx)
+ \\ pop %%eax
+ \\ pop %%ecx
+ \\ ret
+ );
+ unreachable;
+ }
+ }
+
+ @setGlobalLinkage(__chkstk_ms, builtin.GlobalLinkage.Internal);
+}
+
export nakedcc fn ___chkstk_ms() align(4) {
@setDebugSafety(this, false);