about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-03-04 22:58:37 +0100
committerGitHub <noreply@github.com>2022-03-04 22:58:37 +0100
commit629e7aa71803ea3300559e65a4abc17dba984837 (patch)
treea290fa7864da2608b5660753e1057432d421f431
parent3064d6ec4d5f4679ac3c73eaa26a91c5faf63797 (diff)
parent6843dd5013545652ccd1ff3e63462d6cffbe1dcf (diff)
downloadrust-629e7aa71803ea3300559e65a4abc17dba984837.tar.gz
rust-629e7aa71803ea3300559e65a4abc17dba984837.zip
Rollup merge of #94618 - lewisclark:remove-stack-size-rounding, r=yaahc
Don't round stack size up for created threads in Windows

Fixes #94454

Windows does the rounding itself, so there isn't a need to explicity do the rounding beforehand, as mentioned by ```@ChrisDenton``` in #94454

> The operating system rounds up the specified size to the nearest multiple of the system's allocation granularity (typically 64 KB). To retrieve the allocation granularity of the current system, use the [GetSystemInfo](https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsysteminfo) function.

https://docs.microsoft.com/en-us/windows/win32/procthread/thread-stack-size
-rw-r--r--library/std/src/sys/windows/thread.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/library/std/src/sys/windows/thread.rs b/library/std/src/sys/windows/thread.rs
index bd304dc5737..2f469513eb4 100644
--- a/library/std/src/sys/windows/thread.rs
+++ b/library/std/src/sys/windows/thread.rs
@@ -30,12 +30,9 @@ impl Thread {
         // PTHREAD_STACK_MIN bytes big.  Windows has no such lower limit, it's
         // just that below a certain threshold you can't do anything useful.
         // That threshold is application and architecture-specific, however.
-        // Round up to the next 64 kB because that's what the NT kernel does,
-        // might as well make it explicit.
-        let stack_size = (stack + 0xfffe) & (!0xfffe);
         let ret = c::CreateThread(
             ptr::null_mut(),
-            stack_size,
+            stack,
             thread_start,
             p as *mut _,
             c::STACK_SIZE_PARAM_IS_A_RESERVATION,